investigating UART crash
Dependencies: mbed LoRaWAN-lib_publishing_testing_UART_bug SingleFrequencyLora
Fork of simple-demo-76_revised_20171113 by
app/main.cpp@11:32323f490d9e, 2017-11-16 (annotated)
- Committer:
- cdebank
- Date:
- Thu Nov 16 14:30:39 2017 +0000
- Revision:
- 11:32323f490d9e
- Parent:
- 10:9364ab3a08eb
- Child:
- 12:dc90bd3ac7d8
Initial single frequency commit
Who changed what in which revision?
User | Revision | Line number | New 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 | |
cdebank | 11:32323f490d9e | 21 | #define APPDATA_SIZE 7 |
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 | |
cdebank | 11:32323f490d9e | 59 | LoRaMacChannelAdd( 3, ( ChannelParams_t ){ 869400000, { ( ( DR_5 << 4 ) | DR_5 ) }, 3 } ); |
cdebank | 11:32323f490d9e | 60 | //LoRaMacChannelAdd( 4, ( ChannelParams_t ){ 867300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 61 | //LoRaMacChannelAdd( 5, ( ChannelParams_t ){ 867500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 62 | //LoRaMacChannelAdd( 6, ( ChannelParams_t ){ 867700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 63 | //LoRaMacChannelAdd( 7, ( ChannelParams_t ){ 867900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 64 | //LoRaMacChannelAdd( 8, ( ChannelParams_t ){ 868800000, { ( ( DR_7 << 4 ) | DR_7 ) }, 2 } ); |
cdebank | 11:32323f490d9e | 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 | |
cdebank | 11:32323f490d9e | 99 | AppData[0] = 0x43; |
cdebank | 11:32323f490d9e | 100 | AppData[1] = 0x68; |
cdebank | 11:32323f490d9e | 101 | AppData[2] = 0x72; |
cdebank | 11:32323f490d9e | 102 | AppData[3] = 0x69; |
cdebank | 11:32323f490d9e | 103 | AppData[4] = 0x73; |
cdebank | 11:32323f490d9e | 104 | AppData[5] = 0x21; |
cdebank | 11:32323f490d9e | 105 | AppData[6] = 0x21; |
joshcurry | 10:9364ab3a08eb | 106 | |
joshcurry | 10:9364ab3a08eb | 107 | //Sendframe |
joshcurry | 10:9364ab3a08eb | 108 | |
joshcurry | 10:9364ab3a08eb | 109 | McpsReq_t mcpsReq; |
joshcurry | 10:9364ab3a08eb | 110 | |
joshcurry | 10:9364ab3a08eb | 111 | uint8_t AppPort = 3; |
cdebank | 11:32323f490d9e | 112 | mcpsReq.Type = MCPS_UNCONFIRMED; |
cdebank | 11:32323f490d9e | 113 | mcpsReq.Req.Unconfirmed.fPort = AppPort; |
cdebank | 11:32323f490d9e | 114 | mcpsReq.Req.Unconfirmed.fBuffer = AppData; |
cdebank | 11:32323f490d9e | 115 | mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE; |
cdebank | 11:32323f490d9e | 116 | mcpsReq.Req.Unconfirmed.Datarate = DR_5; |
joshcurry | 10:9364ab3a08eb | 117 | |
joshcurry | 10:9364ab3a08eb | 118 | LoRaMacMcpsRequest( &mcpsReq ); |
joshcurry | 10:9364ab3a08eb | 119 | |
cdebank | 11:32323f490d9e | 120 | while(1){ |
cdebank | 11:32323f490d9e | 121 | wait(1); |
cdebank | 11:32323f490d9e | 122 | LoRaMacMcpsRequest( &mcpsReq ); |
cdebank | 11:32323f490d9e | 123 | } |
joshcurry | 10:9364ab3a08eb | 124 | } |
mluis | 3:9c6f7f082151 | 125 |