Lora_with_GPS integration code - program hangs after a few transmissions
Dependencies: mbed LoRaWAN-lib SingleFrequencyLora
Fork of simple-demo-76_revised_20171113 by
app/main.cpp
- Committer:
- joshcurry
- Date:
- 2017-10-30
- Revision:
- 10:9364ab3a08eb
- Parent:
- 9:ee9dcbb9708d
- Child:
- 11:32323f490d9e
File content as of revision 10:9364ab3a08eb:
/* / _____) _ | | ( (____ _____ ____ _| |_ _____ ____| |__ \____ \| ___ | (_ _) ___ |/ ___) _ \ _____) ) ____| | | || |_| ____( (___| | | | (______/|_____)_|_|_| \__)_____)\____)_| |_| (C)2015 Semtech Description: LoRaMac classA device implementation License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Miguel Luis and Gregory Cristian */ #include "mbed.h" #include "board.h" #include "radio.h" #include "LoRaMac.h" #define APPDATA_SIZE 4 #define LORAWAN_DEFAULT_DATARATE DR_0 #define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x01234567 #define LORAWAN_NWKSKEY { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } #define LORAWAN_APPSKEY { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } uint8_t AppData[APPDATA_SIZE]; static uint8_t NwkSKey[] = LORAWAN_NWKSKEY; static uint8_t AppSKey[] = LORAWAN_APPSKEY; void McpsConfirm( McpsConfirm_t *mcpsConfirm ) { return; } void McpsIndication( McpsIndication_t *mcpsIndication ) { return; } int main( void ) { //Initialise firmware LoRaMacPrimitives_t LoRaMacPrimitives; LoRaMacCallback_t LoRaMacCallbacks; MibRequestConfirm_t mibReq; LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm; LoRaMacPrimitives.MacMcpsIndication = McpsIndication; // LoRaMacPrimitives.MacMlmeConfirm = McpsConfirm; LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks ); LoRaMacChannelAdd( 3, ( ChannelParams_t ){ 867100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); LoRaMacChannelAdd( 4, ( ChannelParams_t ){ 867300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }); LoRaMacChannelAdd( 5, ( ChannelParams_t ){ 867500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); LoRaMacChannelAdd( 6, ( ChannelParams_t ){ 867700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); LoRaMacChannelAdd( 7, ( ChannelParams_t ){ 867900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); LoRaMacChannelAdd( 8, ( ChannelParams_t ){ 868800000, { ( ( DR_7 << 4 ) | DR_7 ) }, 2 } ); LoRaMacChannelAdd( 9, ( ChannelParams_t ){ 868300000, { ( ( DR_6 << 4 ) | DR_6 ) }, 1 } ); //Join ABP mibReq.Type = MIB_NET_ID; mibReq.Param.NetID = 0; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_DEV_ADDR; mibReq.Param.DevAddr = LORAWAN_DEVICE_ADDRESS; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_NWK_SKEY; mibReq.Param.NwkSKey = NwkSKey; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_APP_SKEY; mibReq.Param.AppSKey = AppSKey; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_NETWORK_JOINED; mibReq.Param.IsNetworkJoined = true; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_CHANNELS_TX_POWER; mibReq.Param.ChannelsTxPower = LORAMAC_MAX_TX_POWER; LoRaMacMibSetRequestConfirm( &mibReq ); mibReq.Type = MIB_CHANNELS_DEFAULT_TX_POWER; mibReq.Param.ChannelsDefaultTxPower = LORAMAC_MAX_TX_POWER; LoRaMacMibSetRequestConfirm( &mibReq ); //Prepareframe AppData[0] = 0xFF; AppData[1] = 0xFF; AppData[2] = 0xFF; AppData[3] = 0xFF; //Sendframe McpsReq_t mcpsReq; uint8_t AppPort = 3; mcpsReq.Type = MCPS_CONFIRMED; mcpsReq.Req.Confirmed.fPort = AppPort; mcpsReq.Req.Confirmed.fBuffer = AppData; mcpsReq.Req.Confirmed.fBufferSize = APPDATA_SIZE; mcpsReq.Req.Confirmed.Datarate = LORAWAN_DEFAULT_DATARATE; LoRaMacMcpsRequest( &mcpsReq ); while(1); }