LoRa send is causing hang-up when a gps fix is acquired
Dependencies: mbed LoRaWAN-lib_publishing_testing_UART_bug SingleFrequencyLora
Fork of simple-demo-76_revised_20171113_copy by
app/main.cpp@14:539ef77197e0, 2017-12-04 (annotated)
- Committer:
- Rishin
- Date:
- Mon Dec 04 21:25:19 2017 +0000
- Revision:
- 14:539ef77197e0
- Parent:
- 12:dc90bd3ac7d8
initial commit for publish
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 |
Rishin | 12:dc90bd3ac7d8 | 8 | |
mluis | 0:92bca02df485 | 9 | Description: LoRaMac classA device implementation |
Rishin | 12:dc90bd3ac7d8 | 10 | |
mluis | 0:92bca02df485 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
Rishin | 12:dc90bd3ac7d8 | 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" |
Rishin | 12:dc90bd3ac7d8 | 19 | |
Rishin | 12:dc90bd3ac7d8 | 20 | |
Rishin | 12:dc90bd3ac7d8 | 21 | #define APPDATA_SIZE 45 |
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 } |
Rishin | 12:dc90bd3ac7d8 | 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; |
Rishin | 12:dc90bd3ac7d8 | 30 | |
Rishin | 12:dc90bd3ac7d8 | 31 | |
Rishin | 12:dc90bd3ac7d8 | 32 | #include "mbed.h" |
Rishin | 12:dc90bd3ac7d8 | 33 | #include "l86.hpp" |
mluis | 0:92bca02df485 | 34 | |
mluis | 0:92bca02df485 | 35 | |
Rishin | 12:dc90bd3ac7d8 | 36 | // #ifdef DEBUGGER |
Rishin | 14:539ef77197e0 | 37 | RawSerial pc(USBTX, USBRX); // USART2 |
Rishin | 12:dc90bd3ac7d8 | 38 | // #endif |
Rishin | 12:dc90bd3ac7d8 | 39 | |
Rishin | 14:539ef77197e0 | 40 | RawSerial gps(GPS_TX, GPS_RX); // USART1 |
Rishin | 12:dc90bd3ac7d8 | 41 | |
Rishin | 12:dc90bd3ac7d8 | 42 | // DigitalOut Reset(RESET_PIN); |
Rishin | 12:dc90bd3ac7d8 | 43 | // DigitalOut Force_on(FORCE_ON_PIN); |
Rishin | 12:dc90bd3ac7d8 | 44 | DigitalOut GPS_status(GPS_STATUS_LED); |
Rishin | 12:dc90bd3ac7d8 | 45 | // DigitalIn OnePPS(ONEPPS_PIN); |
Rishin | 12:dc90bd3ac7d8 | 46 | |
Rishin | 12:dc90bd3ac7d8 | 47 | RMC_data RMC; |
Rishin | 12:dc90bd3ac7d8 | 48 | GPS_data GPS_parse; |
Rishin | 12:dc90bd3ac7d8 | 49 | volatile int Char_index = 0; // index for char array |
Rishin | 12:dc90bd3ac7d8 | 50 | char Rx_data[MAX_NMEA_LENGTH] = "0"; // char array to store received bytes |
Rishin | 12:dc90bd3ac7d8 | 51 | // uint8_t valid = 0; |
Rishin | 14:539ef77197e0 | 52 | //volatile uint8_t GPS_data_ready = 0; |
Rishin | 12:dc90bd3ac7d8 | 53 | volatile uint8_t sending = 0; |
Rishin | 12:dc90bd3ac7d8 | 54 | |
Rishin | 14:539ef77197e0 | 55 | volatile bool timerset = false; |
Rishin | 12:dc90bd3ac7d8 | 56 | |
Rishin | 14:539ef77197e0 | 57 | volatile bool firstfix = false; |
Rishin | 14:539ef77197e0 | 58 | |
Rishin | 14:539ef77197e0 | 59 | volatile bool keepOut = false; |
Rishin | 12:dc90bd3ac7d8 | 60 | |
Rishin | 12:dc90bd3ac7d8 | 61 | Ticker LoRaSend_timer; |
Rishin | 12:dc90bd3ac7d8 | 62 | |
Rishin | 14:539ef77197e0 | 63 | //void flushSerialBuffer(void) { char char1 = 0; while (gps.readable()) { char1 = gps.getc(); } return; } |
Rishin | 14:539ef77197e0 | 64 | |
Rishin | 14:539ef77197e0 | 65 | void LoRaSend(){ |
Rishin | 14:539ef77197e0 | 66 | //GPS_status = !GPS_status; |
Rishin | 14:539ef77197e0 | 67 | //if (keepOut) |
Rishin | 14:539ef77197e0 | 68 | // return; |
Rishin | 14:539ef77197e0 | 69 | __disable_irq();//NVIC_DisableIRQ(USART1_IRQn); |
Rishin | 14:539ef77197e0 | 70 | //if(GPS_data_ready == 1){ |
Rishin | 14:539ef77197e0 | 71 | // pc.putc('1'); |
Rishin | 14:539ef77197e0 | 72 | sending = 1; |
Rishin | 14:539ef77197e0 | 73 | // pc.putc('3'); |
Rishin | 14:539ef77197e0 | 74 | char AppDatas[APPDATA_SIZE]; |
Rishin | 14:539ef77197e0 | 75 | // pc.putc('4'); |
Rishin | 14:539ef77197e0 | 76 | strcpy(AppDatas, GPS_parse.Latitude); |
Rishin | 14:539ef77197e0 | 77 | // pc.putc('5'); |
Rishin | 14:539ef77197e0 | 78 | strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 79 | // pc.putc('6'); |
Rishin | 14:539ef77197e0 | 80 | strcat(AppDatas, GPS_parse.Longitude); |
Rishin | 14:539ef77197e0 | 81 | // pc.putc('7'); |
Rishin | 14:539ef77197e0 | 82 | strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 83 | // pc.putc('8'); |
Rishin | 14:539ef77197e0 | 84 | strcat(AppDatas, GPS_parse.Course_Over_Ground); |
Rishin | 14:539ef77197e0 | 85 | // pc.putc('9'); |
Rishin | 14:539ef77197e0 | 86 | strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 87 | // pc.putc('a'); |
Rishin | 14:539ef77197e0 | 88 | strcat(AppDatas, GPS_parse.Speed_Over_Ground); |
Rishin | 14:539ef77197e0 | 89 | // pc.putc('b'); |
Rishin | 14:539ef77197e0 | 90 | strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 91 | //strcat(AppDatas, GPS_parse.Date); |
Rishin | 14:539ef77197e0 | 92 | //strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 93 | // pc.putc('c'); |
Rishin | 14:539ef77197e0 | 94 | strcat(AppDatas, GPS_parse.UTC_Time); |
Rishin | 14:539ef77197e0 | 95 | // pc.putc('d'); |
Rishin | 14:539ef77197e0 | 96 | strcat(AppDatas, ","); |
Rishin | 14:539ef77197e0 | 97 | // pc.putc('e'); |
Rishin | 14:539ef77197e0 | 98 | strcat(AppDatas, GPS_parse.Valid); |
Rishin | 14:539ef77197e0 | 99 | // pc.putc('f'); |
Rishin | 14:539ef77197e0 | 100 | // McpsReq_t mcpsReq; |
Rishin | 14:539ef77197e0 | 101 | // pc.putc('g'); |
Rishin | 14:539ef77197e0 | 102 | // uint8_t AppPort = 3; |
Rishin | 14:539ef77197e0 | 103 | // pc.putc('h'); |
Rishin | 14:539ef77197e0 | 104 | // mcpsReq.Type = MCPS_UNCONFIRMED; |
Rishin | 14:539ef77197e0 | 105 | // pc.putc('i'); |
Rishin | 14:539ef77197e0 | 106 | // mcpsReq.Req.Unconfirmed.fPort = AppPort; |
Rishin | 14:539ef77197e0 | 107 | // pc.putc('j'); |
Rishin | 14:539ef77197e0 | 108 | // mcpsReq.Req.Unconfirmed.fBuffer = AppDatas; |
Rishin | 14:539ef77197e0 | 109 | // pc.putc('k'); |
Rishin | 14:539ef77197e0 | 110 | // mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE+2; |
Rishin | 14:539ef77197e0 | 111 | // pc.putc('l'); |
Rishin | 14:539ef77197e0 | 112 | // mcpsReq.Req.Unconfirmed.Datarate = DR_5; |
Rishin | 14:539ef77197e0 | 113 | // status = !status; |
Rishin | 14:539ef77197e0 | 114 | //GPS_status = !GPS_status; |
Rishin | 14:539ef77197e0 | 115 | // pc.putc('m'); |
Rishin | 14:539ef77197e0 | 116 | // LoRaMacMcpsRequest( &mcpsReq ); |
Rishin | 14:539ef77197e0 | 117 | // GPS_data_ready = 0; |
Rishin | 14:539ef77197e0 | 118 | // Ready_for_more = 1; |
Rishin | 14:539ef77197e0 | 119 | //} |
Rishin | 14:539ef77197e0 | 120 | sending = 0; |
Rishin | 14:539ef77197e0 | 121 | __enable_irq();//NVIC_EnableIRQ(USART1_IRQn); |
Rishin | 14:539ef77197e0 | 122 | pc.putc('N'); |
Rishin | 14:539ef77197e0 | 123 | } |
Rishin | 14:539ef77197e0 | 124 | |
Rishin | 12:dc90bd3ac7d8 | 125 | |
Rishin | 12:dc90bd3ac7d8 | 126 | void gps_receive(void) { |
Rishin | 12:dc90bd3ac7d8 | 127 | // Note: you need to actually read from the serial to clear the RX interrupt |
Rishin | 14:539ef77197e0 | 128 | __disable_irq(); |
Rishin | 14:539ef77197e0 | 129 | keepOut = true; // |
Rishin | 14:539ef77197e0 | 130 | while(gps.readable()) { |
Rishin | 12:dc90bd3ac7d8 | 131 | char incoming = gps.getc(); |
Rishin | 12:dc90bd3ac7d8 | 132 | // #ifdef DEBUGGER |
Rishin | 12:dc90bd3ac7d8 | 133 | // pc.putc(incoming); |
Rishin | 12:dc90bd3ac7d8 | 134 | // #endif |
Rishin | 12:dc90bd3ac7d8 | 135 | Rx_data[Char_index] = incoming; |
Rishin | 12:dc90bd3ac7d8 | 136 | |
Rishin | 14:539ef77197e0 | 137 | if((Rx_data[Char_index] == '\n')){ // Received the end of an NMEA scentence |
Rishin | 14:539ef77197e0 | 138 | if((strncmp(GPRMC_Tag,Rx_data,(sizeof(GPRMC_Tag)-1)) == 0) || (strncmp(GNRMC_Tag,Rx_data,(sizeof(GNRMC_Tag)-1)) == 0)){ |
Rishin | 12:dc90bd3ac7d8 | 139 | RMC = Parse_RMC_sentence(Rx_data); |
Rishin | 14:539ef77197e0 | 140 | if(strcmp(RMC.Status, "A") == 0){ |
Rishin | 14:539ef77197e0 | 141 | // valid = 1; |
Rishin | 14:539ef77197e0 | 142 | // GPS_status = 0; // Turn status LED off |
Rishin | 14:539ef77197e0 | 143 | // GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software) |
Rishin | 14:539ef77197e0 | 144 | // Call function to send using LoRa module |
Rishin | 14:539ef77197e0 | 145 | // LoRaSend(); |
Rishin | 14:539ef77197e0 | 146 | // pc.putc('O'); |
Rishin | 14:539ef77197e0 | 147 | if(timerset == false) |
Rishin | 14:539ef77197e0 | 148 | firstfix = true; |
Rishin | 14:539ef77197e0 | 149 | /* |
Rishin | 14:539ef77197e0 | 150 | if(firstfix == false) // |
Rishin | 14:539ef77197e0 | 151 | { // |
Rishin | 14:539ef77197e0 | 152 | //LoRaSend_timer.attach(&LoRaSend, 1.0); // |
Rishin | 14:539ef77197e0 | 153 | firstfix = true; // |
Rishin | 14:539ef77197e0 | 154 | } */ // |
Rishin | 12:dc90bd3ac7d8 | 155 | } |
Rishin | 14:539ef77197e0 | 156 | else{ |
Rishin | 12:dc90bd3ac7d8 | 157 | // GPS_status = 1; |
Rishin | 14:539ef77197e0 | 158 | // Send "No GPS fix" over LoRa? |
Rishin | 12:dc90bd3ac7d8 | 159 | } |
Rishin | 14:539ef77197e0 | 160 | ///* |
Rishin | 14:539ef77197e0 | 161 | if (sending) // |
Rishin | 14:539ef77197e0 | 162 | { // |
Rishin | 14:539ef77197e0 | 163 | Char_index = 0; // |
Rishin | 14:539ef77197e0 | 164 | memset(Rx_data,0,sizeof(Rx_data)); // |
Rishin | 14:539ef77197e0 | 165 | __enable_irq(); // |
Rishin | 14:539ef77197e0 | 166 | keepOut = false; // |
Rishin | 14:539ef77197e0 | 167 | return; // |
Rishin | 14:539ef77197e0 | 168 | } //*/ // |
Rishin | 14:539ef77197e0 | 169 | GPS_status=!GPS_status; |
Rishin | 14:539ef77197e0 | 170 | // delete this line |
Rishin | 14:539ef77197e0 | 171 | //GPS_data_ready = 0; |
Rishin | 12:dc90bd3ac7d8 | 172 | GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software) |
Rishin | 14:539ef77197e0 | 173 | //GPS_data_ready = 1; |
Rishin | 14:539ef77197e0 | 174 | |
Rishin | 14:539ef77197e0 | 175 | |
Rishin | 12:dc90bd3ac7d8 | 176 | } |
Rishin | 12:dc90bd3ac7d8 | 177 | Char_index = 0; |
Rishin | 12:dc90bd3ac7d8 | 178 | memset(Rx_data,0,sizeof(Rx_data)); |
Rishin | 12:dc90bd3ac7d8 | 179 | } |
Rishin | 12:dc90bd3ac7d8 | 180 | else |
Rishin | 12:dc90bd3ac7d8 | 181 | Char_index++; |
Rishin | 12:dc90bd3ac7d8 | 182 | } |
Rishin | 12:dc90bd3ac7d8 | 183 | keepOut = false; |
Rishin | 12:dc90bd3ac7d8 | 184 | __enable_irq(); |
Rishin | 14:539ef77197e0 | 185 | // put first fix code here if above doesn't work |
Rishin | 12:dc90bd3ac7d8 | 186 | return; |
Rishin | 14:539ef77197e0 | 187 | // store chars into a string then process into LAT, LONG, SOG, COG & DATETIME, VALID/INVLAID |
Rishin | 12:dc90bd3ac7d8 | 188 | } |
mluis | 0:92bca02df485 | 189 | |
joshcurry | 10:9364ab3a08eb | 190 | void McpsConfirm( McpsConfirm_t *mcpsConfirm ) |
mluis | 0:92bca02df485 | 191 | { |
joshcurry | 10:9364ab3a08eb | 192 | return; |
mluis | 0:92bca02df485 | 193 | } |
Rishin | 12:dc90bd3ac7d8 | 194 | |
joshcurry | 10:9364ab3a08eb | 195 | void McpsIndication( McpsIndication_t *mcpsIndication ) |
mluis | 0:92bca02df485 | 196 | { |
joshcurry | 10:9364ab3a08eb | 197 | return; |
mluis | 3:9c6f7f082151 | 198 | } |
Rishin | 12:dc90bd3ac7d8 | 199 | |
joshcurry | 10:9364ab3a08eb | 200 | |
mluis | 0:92bca02df485 | 201 | int main( void ) |
mluis | 0:92bca02df485 | 202 | { |
joshcurry | 10:9364ab3a08eb | 203 | //Initialise firmware |
joshcurry | 10:9364ab3a08eb | 204 | |
mluis | 3:9c6f7f082151 | 205 | LoRaMacPrimitives_t LoRaMacPrimitives; |
mluis | 3:9c6f7f082151 | 206 | LoRaMacCallback_t LoRaMacCallbacks; |
mluis | 3:9c6f7f082151 | 207 | MibRequestConfirm_t mibReq; |
Rishin | 12:dc90bd3ac7d8 | 208 | |
joshcurry | 10:9364ab3a08eb | 209 | LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm; |
joshcurry | 10:9364ab3a08eb | 210 | LoRaMacPrimitives.MacMcpsIndication = McpsIndication; |
joshcurry | 10:9364ab3a08eb | 211 | // LoRaMacPrimitives.MacMlmeConfirm = McpsConfirm; |
joshcurry | 10:9364ab3a08eb | 212 | LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks ); |
Rishin | 12:dc90bd3ac7d8 | 213 | |
Rishin | 12:dc90bd3ac7d8 | 214 | LoRaMacChannelAdd( 3, ( ChannelParams_t ){ 868100000, { ( ( DR_5 << 4 ) | DR_5 ) }, 3 } ); |
cdebank | 11:32323f490d9e | 215 | //LoRaMacChannelAdd( 4, ( ChannelParams_t ){ 867300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 216 | //LoRaMacChannelAdd( 5, ( ChannelParams_t ){ 867500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 217 | //LoRaMacChannelAdd( 6, ( ChannelParams_t ){ 867700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 218 | //LoRaMacChannelAdd( 7, ( ChannelParams_t ){ 867900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } ); |
cdebank | 11:32323f490d9e | 219 | //LoRaMacChannelAdd( 8, ( ChannelParams_t ){ 868800000, { ( ( DR_7 << 4 ) | DR_7 ) }, 2 } ); |
cdebank | 11:32323f490d9e | 220 | //LoRaMacChannelAdd( 9, ( ChannelParams_t ){ 868300000, { ( ( DR_6 << 4 ) | DR_6 ) }, 1 } ); |
Rishin | 12:dc90bd3ac7d8 | 221 | |
joshcurry | 10:9364ab3a08eb | 222 | //Join ABP |
Rishin | 12:dc90bd3ac7d8 | 223 | |
joshcurry | 10:9364ab3a08eb | 224 | mibReq.Type = MIB_NET_ID; |
joshcurry | 10:9364ab3a08eb | 225 | mibReq.Param.NetID = 0; |
joshcurry | 10:9364ab3a08eb | 226 | LoRaMacMibSetRequestConfirm( &mibReq ); |
Rishin | 12:dc90bd3ac7d8 | 227 | |
joshcurry | 10:9364ab3a08eb | 228 | mibReq.Type = MIB_DEV_ADDR; |
joshcurry | 10:9364ab3a08eb | 229 | mibReq.Param.DevAddr = LORAWAN_DEVICE_ADDRESS; |
joshcurry | 10:9364ab3a08eb | 230 | LoRaMacMibSetRequestConfirm( &mibReq ); |
Rishin | 12:dc90bd3ac7d8 | 231 | |
joshcurry | 10:9364ab3a08eb | 232 | mibReq.Type = MIB_NWK_SKEY; |
joshcurry | 10:9364ab3a08eb | 233 | mibReq.Param.NwkSKey = NwkSKey; |
joshcurry | 10:9364ab3a08eb | 234 | LoRaMacMibSetRequestConfirm( &mibReq ); |
Rishin | 12:dc90bd3ac7d8 | 235 | |
joshcurry | 10:9364ab3a08eb | 236 | mibReq.Type = MIB_APP_SKEY; |
joshcurry | 10:9364ab3a08eb | 237 | mibReq.Param.AppSKey = AppSKey; |
joshcurry | 10:9364ab3a08eb | 238 | LoRaMacMibSetRequestConfirm( &mibReq ); |
Rishin | 12:dc90bd3ac7d8 | 239 | |
joshcurry | 10:9364ab3a08eb | 240 | mibReq.Type = MIB_NETWORK_JOINED; |
joshcurry | 10:9364ab3a08eb | 241 | mibReq.Param.IsNetworkJoined = true; |
joshcurry | 10:9364ab3a08eb | 242 | LoRaMacMibSetRequestConfirm( &mibReq ); |
joshcurry | 10:9364ab3a08eb | 243 | |
joshcurry | 10:9364ab3a08eb | 244 | mibReq.Type = MIB_CHANNELS_TX_POWER; |
joshcurry | 10:9364ab3a08eb | 245 | mibReq.Param.ChannelsTxPower = LORAMAC_MAX_TX_POWER; |
joshcurry | 10:9364ab3a08eb | 246 | LoRaMacMibSetRequestConfirm( &mibReq ); |
joshcurry | 10:9364ab3a08eb | 247 | |
joshcurry | 10:9364ab3a08eb | 248 | mibReq.Type = MIB_CHANNELS_DEFAULT_TX_POWER; |
joshcurry | 10:9364ab3a08eb | 249 | mibReq.Param.ChannelsDefaultTxPower = LORAMAC_MAX_TX_POWER; |
joshcurry | 10:9364ab3a08eb | 250 | LoRaMacMibSetRequestConfirm( &mibReq ); |
Rishin | 12:dc90bd3ac7d8 | 251 | |
Rishin | 12:dc90bd3ac7d8 | 252 | /*//Prepareframe |
Rishin | 12:dc90bd3ac7d8 | 253 | |
cdebank | 11:32323f490d9e | 254 | AppData[0] = 0x43; |
cdebank | 11:32323f490d9e | 255 | AppData[1] = 0x68; |
cdebank | 11:32323f490d9e | 256 | AppData[2] = 0x72; |
cdebank | 11:32323f490d9e | 257 | AppData[3] = 0x69; |
cdebank | 11:32323f490d9e | 258 | AppData[4] = 0x73; |
cdebank | 11:32323f490d9e | 259 | AppData[5] = 0x21; |
cdebank | 11:32323f490d9e | 260 | AppData[6] = 0x21; |
joshcurry | 10:9364ab3a08eb | 261 | |
joshcurry | 10:9364ab3a08eb | 262 | //Sendframe |
joshcurry | 10:9364ab3a08eb | 263 | |
joshcurry | 10:9364ab3a08eb | 264 | McpsReq_t mcpsReq; |
Rishin | 14:539ef77197e0 | 265 | |
joshcurry | 10:9364ab3a08eb | 266 | uint8_t AppPort = 3; |
cdebank | 11:32323f490d9e | 267 | mcpsReq.Type = MCPS_UNCONFIRMED; |
cdebank | 11:32323f490d9e | 268 | mcpsReq.Req.Unconfirmed.fPort = AppPort; |
cdebank | 11:32323f490d9e | 269 | mcpsReq.Req.Unconfirmed.fBuffer = AppData; |
cdebank | 11:32323f490d9e | 270 | mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE; |
cdebank | 11:32323f490d9e | 271 | mcpsReq.Req.Unconfirmed.Datarate = DR_5; |
joshcurry | 10:9364ab3a08eb | 272 | |
Rishin | 12:dc90bd3ac7d8 | 273 | LoRaMacMcpsRequest( &mcpsReq );*/ |
Rishin | 12:dc90bd3ac7d8 | 274 | GPS_status = 1; |
Rishin | 12:dc90bd3ac7d8 | 275 | gps.attach(&gps_receive, Serial::RxIrq); |
Rishin | 12:dc90bd3ac7d8 | 276 | gps.printf(PMTK_SET_NMEA_OUTPUT_RMC); // Only output RMC and GPTXT |
Rishin | 12:dc90bd3ac7d8 | 277 | wait(1.0); |
Rishin | 12:dc90bd3ac7d8 | 278 | gps.printf(PMTK_SET_UPDATE_F_2HZ); // Set update Frequency to 2Hz |
Rishin | 12:dc90bd3ac7d8 | 279 | wait(1.0); |
Rishin | 12:dc90bd3ac7d8 | 280 | gps.printf(PMTK_SET_NMEA_OUTPUT_RMC); // Only output RMC and GPTXT |
Rishin | 12:dc90bd3ac7d8 | 281 | wait(1.0); |
Rishin | 12:dc90bd3ac7d8 | 282 | gps.printf(PMTK_SET_UPDATE_F_2HZ); // Set update Frequency to 2Hz |
Rishin | 12:dc90bd3ac7d8 | 283 | wait(1.0); |
Rishin | 12:dc90bd3ac7d8 | 284 | gps.printf(PMTK_SET_NMEA_OUTPUT_RMC); // Only output RMC and GPTXT |
Rishin | 12:dc90bd3ac7d8 | 285 | wait(1.0); |
Rishin | 12:dc90bd3ac7d8 | 286 | gps.printf(PMTK_SET_UPDATE_F_2HZ); // Set update Frequency to 2Hz |
Rishin | 14:539ef77197e0 | 287 | //LoRaSend_timer.attach(&LoRaSend, 1.0); |
cdebank | 11:32323f490d9e | 288 | while(1){ |
Rishin | 14:539ef77197e0 | 289 | if(sending==0){ |
Rishin | 14:539ef77197e0 | 290 | Print_GPS_data(GPS_parse); |
Rishin | 14:539ef77197e0 | 291 | } |
Rishin | 14:539ef77197e0 | 292 | if(firstfix){ |
Rishin | 14:539ef77197e0 | 293 | LoRaSend_timer.attach(&LoRaSend, 1.0); |
Rishin | 14:539ef77197e0 | 294 | firstfix = false; |
Rishin | 14:539ef77197e0 | 295 | timerset = true; |
Rishin | 14:539ef77197e0 | 296 | } |
Rishin | 14:539ef77197e0 | 297 | wait(0.5); |
cdebank | 11:32323f490d9e | 298 | } |
Rishin | 12:dc90bd3ac7d8 | 299 | } |