investigating UART crash

Dependencies:   mbed LoRaWAN-lib_publishing_testing_UART_bug SingleFrequencyLora

Fork of simple-demo-76_revised_20171113 by Christopher De Bank

Committer:
joshcurry
Date:
Mon Oct 30 10:51:44 2017 +0000
Revision:
10:9364ab3a08eb
Parent:
9:ee9dcbb9708d
Child:
11:32323f490d9e
Simplified Code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 0:92bca02df485 1 /*
mluis 0:92bca02df485 2 / _____) _ | |
mluis 0:92bca02df485 3 ( (____ _____ ____ _| |_ _____ ____| |__
mluis 0:92bca02df485 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
mluis 0:92bca02df485 5 _____) ) ____| | | || |_| ____( (___| | | |
mluis 0:92bca02df485 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
mluis 0:92bca02df485 7 (C)2015 Semtech
mluis 0:92bca02df485 8
mluis 0:92bca02df485 9 Description: LoRaMac classA device implementation
mluis 0:92bca02df485 10
mluis 0:92bca02df485 11 License: Revised BSD License, see LICENSE.TXT file include in the project
mluis 0:92bca02df485 12
mluis 0:92bca02df485 13 Maintainer: Miguel Luis and Gregory Cristian
mluis 0:92bca02df485 14 */
mluis 0:92bca02df485 15 #include "mbed.h"
mluis 0:92bca02df485 16 #include "board.h"
mluis 0:92bca02df485 17 #include "radio.h"
mluis 0:92bca02df485 18 #include "LoRaMac.h"
mluis 0:92bca02df485 19
mluis 3:9c6f7f082151 20
joshcurry 10:9364ab3a08eb 21 #define APPDATA_SIZE 4
joshcurry 10:9364ab3a08eb 22 #define LORAWAN_DEFAULT_DATARATE DR_0
joshcurry 10:9364ab3a08eb 23 #define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x01234567
joshcurry 10:9364ab3a08eb 24 #define LORAWAN_NWKSKEY { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }
joshcurry 10:9364ab3a08eb 25 #define LORAWAN_APPSKEY { 0x11, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }
mluis 1:352f608c3337 26
joshcurry 10:9364ab3a08eb 27 uint8_t AppData[APPDATA_SIZE];
mluis 0:92bca02df485 28 static uint8_t NwkSKey[] = LORAWAN_NWKSKEY;
mluis 0:92bca02df485 29 static uint8_t AppSKey[] = LORAWAN_APPSKEY;
mluis 0:92bca02df485 30
mluis 0:92bca02df485 31
mluis 0:92bca02df485 32
joshcurry 10:9364ab3a08eb 33 void McpsConfirm( McpsConfirm_t *mcpsConfirm )
mluis 0:92bca02df485 34 {
joshcurry 10:9364ab3a08eb 35 return;
mluis 0:92bca02df485 36 }
mluis 0:92bca02df485 37
joshcurry 10:9364ab3a08eb 38 void McpsIndication( McpsIndication_t *mcpsIndication )
mluis 0:92bca02df485 39 {
joshcurry 10:9364ab3a08eb 40 return;
mluis 3:9c6f7f082151 41 }
mluis 3:9c6f7f082151 42
mluis 3:9c6f7f082151 43
mluis 9:ee9dcbb9708d 44
joshcurry 10:9364ab3a08eb 45
mluis 0:92bca02df485 46 int main( void )
mluis 0:92bca02df485 47 {
joshcurry 10:9364ab3a08eb 48 //Initialise firmware
joshcurry 10:9364ab3a08eb 49
mluis 3:9c6f7f082151 50 LoRaMacPrimitives_t LoRaMacPrimitives;
mluis 3:9c6f7f082151 51 LoRaMacCallback_t LoRaMacCallbacks;
mluis 3:9c6f7f082151 52 MibRequestConfirm_t mibReq;
mluis 0:92bca02df485 53
joshcurry 10:9364ab3a08eb 54 LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm;
joshcurry 10:9364ab3a08eb 55 LoRaMacPrimitives.MacMcpsIndication = McpsIndication;
joshcurry 10:9364ab3a08eb 56 // LoRaMacPrimitives.MacMlmeConfirm = McpsConfirm;
joshcurry 10:9364ab3a08eb 57 LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks );
mluis 7:3173f0508a98 58
joshcurry 10:9364ab3a08eb 59 LoRaMacChannelAdd( 3, ( ChannelParams_t ){ 867100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } );
joshcurry 10:9364ab3a08eb 60 LoRaMacChannelAdd( 4, ( ChannelParams_t ){ 867300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 });
joshcurry 10:9364ab3a08eb 61 LoRaMacChannelAdd( 5, ( ChannelParams_t ){ 867500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } );
joshcurry 10:9364ab3a08eb 62 LoRaMacChannelAdd( 6, ( ChannelParams_t ){ 867700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } );
joshcurry 10:9364ab3a08eb 63 LoRaMacChannelAdd( 7, ( ChannelParams_t ){ 867900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } );
joshcurry 10:9364ab3a08eb 64 LoRaMacChannelAdd( 8, ( ChannelParams_t ){ 868800000, { ( ( DR_7 << 4 ) | DR_7 ) }, 2 } );
joshcurry 10:9364ab3a08eb 65 LoRaMacChannelAdd( 9, ( ChannelParams_t ){ 868300000, { ( ( DR_6 << 4 ) | DR_6 ) }, 1 } );
mluis 7:3173f0508a98 66
joshcurry 10:9364ab3a08eb 67 //Join ABP
mluis 0:92bca02df485 68
joshcurry 10:9364ab3a08eb 69 mibReq.Type = MIB_NET_ID;
joshcurry 10:9364ab3a08eb 70 mibReq.Param.NetID = 0;
joshcurry 10:9364ab3a08eb 71 LoRaMacMibSetRequestConfirm( &mibReq );
joshcurry 10:9364ab3a08eb 72
joshcurry 10:9364ab3a08eb 73 mibReq.Type = MIB_DEV_ADDR;
joshcurry 10:9364ab3a08eb 74 mibReq.Param.DevAddr = LORAWAN_DEVICE_ADDRESS;
joshcurry 10:9364ab3a08eb 75 LoRaMacMibSetRequestConfirm( &mibReq );
mluis 3:9c6f7f082151 76
joshcurry 10:9364ab3a08eb 77 mibReq.Type = MIB_NWK_SKEY;
joshcurry 10:9364ab3a08eb 78 mibReq.Param.NwkSKey = NwkSKey;
joshcurry 10:9364ab3a08eb 79 LoRaMacMibSetRequestConfirm( &mibReq );
mluis 3:9c6f7f082151 80
joshcurry 10:9364ab3a08eb 81 mibReq.Type = MIB_APP_SKEY;
joshcurry 10:9364ab3a08eb 82 mibReq.Param.AppSKey = AppSKey;
joshcurry 10:9364ab3a08eb 83 LoRaMacMibSetRequestConfirm( &mibReq );
mluis 9:ee9dcbb9708d 84
joshcurry 10:9364ab3a08eb 85 mibReq.Type = MIB_NETWORK_JOINED;
joshcurry 10:9364ab3a08eb 86 mibReq.Param.IsNetworkJoined = true;
joshcurry 10:9364ab3a08eb 87 LoRaMacMibSetRequestConfirm( &mibReq );
joshcurry 10:9364ab3a08eb 88
joshcurry 10:9364ab3a08eb 89 mibReq.Type = MIB_CHANNELS_TX_POWER;
joshcurry 10:9364ab3a08eb 90 mibReq.Param.ChannelsTxPower = LORAMAC_MAX_TX_POWER;
joshcurry 10:9364ab3a08eb 91 LoRaMacMibSetRequestConfirm( &mibReq );
joshcurry 10:9364ab3a08eb 92
joshcurry 10:9364ab3a08eb 93 mibReq.Type = MIB_CHANNELS_DEFAULT_TX_POWER;
joshcurry 10:9364ab3a08eb 94 mibReq.Param.ChannelsDefaultTxPower = LORAMAC_MAX_TX_POWER;
joshcurry 10:9364ab3a08eb 95 LoRaMacMibSetRequestConfirm( &mibReq );
mluis 3:9c6f7f082151 96
joshcurry 10:9364ab3a08eb 97 //Prepareframe
mluis 3:9c6f7f082151 98
joshcurry 10:9364ab3a08eb 99 AppData[0] = 0xFF;
joshcurry 10:9364ab3a08eb 100 AppData[1] = 0xFF;
joshcurry 10:9364ab3a08eb 101 AppData[2] = 0xFF;
joshcurry 10:9364ab3a08eb 102 AppData[3] = 0xFF;
joshcurry 10:9364ab3a08eb 103
joshcurry 10:9364ab3a08eb 104 //Sendframe
joshcurry 10:9364ab3a08eb 105
joshcurry 10:9364ab3a08eb 106 McpsReq_t mcpsReq;
joshcurry 10:9364ab3a08eb 107
joshcurry 10:9364ab3a08eb 108 uint8_t AppPort = 3;
joshcurry 10:9364ab3a08eb 109 mcpsReq.Type = MCPS_CONFIRMED;
joshcurry 10:9364ab3a08eb 110 mcpsReq.Req.Confirmed.fPort = AppPort;
joshcurry 10:9364ab3a08eb 111 mcpsReq.Req.Confirmed.fBuffer = AppData;
joshcurry 10:9364ab3a08eb 112 mcpsReq.Req.Confirmed.fBufferSize = APPDATA_SIZE;
joshcurry 10:9364ab3a08eb 113 mcpsReq.Req.Confirmed.Datarate = LORAWAN_DEFAULT_DATARATE;
joshcurry 10:9364ab3a08eb 114
joshcurry 10:9364ab3a08eb 115 LoRaMacMcpsRequest( &mcpsReq );
joshcurry 10:9364ab3a08eb 116
joshcurry 10:9364ab3a08eb 117 while(1);
joshcurry 10:9364ab3a08eb 118 }
mluis 3:9c6f7f082151 119