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/l86.hpp@12:7debb1c79a06, 2017-11-20 (annotated)
- Committer:
- Rishin
- Date:
- Mon Nov 20 12:03:22 2017 +0000
- Revision:
- 12:7debb1c79a06
Sending GPS data every 5 seconds, but program is crashing - possibly due to memory issues - try passing structs by reference
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rishin | 12:7debb1c79a06 | 1 | /* |
Rishin | 12:7debb1c79a06 | 2 | * l86.h |
Rishin | 12:7debb1c79a06 | 3 | * Author: Rishin Amin |
Rishin | 12:7debb1c79a06 | 4 | * library header file for communication with the Quectel L86 MT33 GPS module |
Rishin | 12:7debb1c79a06 | 5 | * |
Rishin | 12:7debb1c79a06 | 6 | */ |
Rishin | 12:7debb1c79a06 | 7 | #ifndef l86_hpp |
Rishin | 12:7debb1c79a06 | 8 | #define l86_hpp |
Rishin | 12:7debb1c79a06 | 9 | #include "board.h" |
Rishin | 12:7debb1c79a06 | 10 | #include "radio.h" |
Rishin | 12:7debb1c79a06 | 11 | #include "LoRaMac.h" |
Rishin | 12:7debb1c79a06 | 12 | |
Rishin | 12:7debb1c79a06 | 13 | #define DEBUGGER // uncomment to output serial data to PC |
Rishin | 12:7debb1c79a06 | 14 | |
Rishin | 12:7debb1c79a06 | 15 | /* PIN DEFINITIONS */ |
Rishin | 12:7debb1c79a06 | 16 | #define RESET_PIN PC_14 |
Rishin | 12:7debb1c79a06 | 17 | #define FORCE_ON_PIN PC_12 |
Rishin | 12:7debb1c79a06 | 18 | // #define ONEPPS_PIN PC_10 |
Rishin | 12:7debb1c79a06 | 19 | #define GPS_RX PA_10 |
Rishin | 12:7debb1c79a06 | 20 | #define GPS_TX PA_9 |
Rishin | 12:7debb1c79a06 | 21 | #define PC_RX PC_5 |
Rishin | 12:7debb1c79a06 | 22 | #define PC_TX PC_4 |
Rishin | 12:7debb1c79a06 | 23 | #define GPS_STATUS_LED LED1 |
Rishin | 12:7debb1c79a06 | 24 | |
Rishin | 12:7debb1c79a06 | 25 | /* PMTK MMESSAGE DEFINITIONS */ |
Rishin | 12:7debb1c79a06 | 26 | #define MAX_NMEA_LENGTH 82 // maximum length of an NMEA sentence |
Rishin | 12:7debb1c79a06 | 27 | #define PMTK_SET_NMEA_OUTPUT_RMC "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n" |
Rishin | 12:7debb1c79a06 | 28 | #define PMTK_SET_UPDATE_F_2HZ "$PMTK300,500,0,0,0,0*28\r\n" |
Rishin | 12:7debb1c79a06 | 29 | #define PMTK_COLD_RESTART "$PMTK104*37\r\n" |
Rishin | 12:7debb1c79a06 | 30 | #define PMTK_WARM_START "$PMTK102*31\r\n" |
Rishin | 12:7debb1c79a06 | 31 | #define PMTK_HOT_START "$PMTK101*32\r\n" |
Rishin | 12:7debb1c79a06 | 32 | #define PMTK_ALWAYS_LOCATE_STANDDBY "$PMTK225,8*23\r\n" |
Rishin | 12:7debb1c79a06 | 33 | #define PMTK_ALWAYS_LOCATE_BACKUP "$PMTK225,922\r\n*" |
Rishin | 12:7debb1c79a06 | 34 | #define PMTK_STANDBY_MODE "$PMTK161,0*28\r\n" // Any UART data will retrun to Full-on mode |
Rishin | 12:7debb1c79a06 | 35 | #define PMTK_BACKUP_MODE "$PMTK225,4*2F\r\n" // Force_on must be low before entering backup mode! |
Rishin | 12:7debb1c79a06 | 36 | // Pull Force_on high to exit backup mode |
Rishin | 12:7debb1c79a06 | 37 | |
Rishin | 12:7debb1c79a06 | 38 | /* Size of packet being transmitted over LoRa */ |
Rishin | 12:7debb1c79a06 | 39 | #define APPDATA_SIZE 49 |
Rishin | 12:7debb1c79a06 | 40 | |
Rishin | 12:7debb1c79a06 | 41 | static const char GPRMC_Tag[] = "$GPRMC"; |
Rishin | 12:7debb1c79a06 | 42 | static const char GNRMC_Tag[] = "$GNRMC"; |
Rishin | 12:7debb1c79a06 | 43 | |
Rishin | 12:7debb1c79a06 | 44 | typedef struct RMC_data |
Rishin | 12:7debb1c79a06 | 45 | { |
Rishin | 12:7debb1c79a06 | 46 | char Message[MAX_NMEA_LENGTH]; /* Un-parsed NMEA sentence */ |
Rishin | 12:7debb1c79a06 | 47 | char Message_ID[7]; /* RMC Protocol header */ |
Rishin | 12:7debb1c79a06 | 48 | char UTC_Time[11]; /* hhmmss.sss */ |
Rishin | 12:7debb1c79a06 | 49 | char Status[2]; /* A = data valid, V = data NOT valid */ |
Rishin | 12:7debb1c79a06 | 50 | char Latitude[10]; /* ddmm.mmmm */ |
Rishin | 12:7debb1c79a06 | 51 | char N_S_Indicator[3]; /* N = North, S = South */ |
Rishin | 12:7debb1c79a06 | 52 | char Longitude[11]; /* dddmm.mmmm */ |
Rishin | 12:7debb1c79a06 | 53 | char E_W_Indicator[3]; /* E = East, W = West */ |
Rishin | 12:7debb1c79a06 | 54 | char Speed_Over_Ground[5]; /* In Knots */ |
Rishin | 12:7debb1c79a06 | 55 | char Course_Over_Ground[7]; /* Degrees */ |
Rishin | 12:7debb1c79a06 | 56 | char Date[7]; /* ddmmyy */ |
Rishin | 12:7debb1c79a06 | 57 | char Mode[5]; /* N = No Fix, A = autonomous mode, D = Differential mode + checksum */ |
Rishin | 12:7debb1c79a06 | 58 | }RMC_data; |
Rishin | 12:7debb1c79a06 | 59 | |
Rishin | 12:7debb1c79a06 | 60 | typedef struct GPS_data |
Rishin | 12:7debb1c79a06 | 61 | { |
Rishin | 12:7debb1c79a06 | 62 | char UTC_Time[11]; |
Rishin | 12:7debb1c79a06 | 63 | char Latitude[11]; |
Rishin | 12:7debb1c79a06 | 64 | char Longitude[12]; |
Rishin | 12:7debb1c79a06 | 65 | char Speed_Over_Ground[5]; |
Rishin | 12:7debb1c79a06 | 66 | char Course_Over_Ground[7]; |
Rishin | 12:7debb1c79a06 | 67 | char Date[7]; |
Rishin | 12:7debb1c79a06 | 68 | char Valid[2]; |
Rishin | 12:7debb1c79a06 | 69 | }GPS_data; |
Rishin | 12:7debb1c79a06 | 70 | |
Rishin | 12:7debb1c79a06 | 71 | RMC_data Parse_RMC_sentence(char RMC_sentence[MAX_NMEA_LENGTH]); |
Rishin | 12:7debb1c79a06 | 72 | void Print_RMC_data(RMC_data *RMC_data_print); |
Rishin | 12:7debb1c79a06 | 73 | GPS_data Parse_RMC_data(RMC_data RMC_parsed); |
Rishin | 12:7debb1c79a06 | 74 | void Print_GPS_data(GPS_data GPS_data_print); |
Rishin | 12:7debb1c79a06 | 75 | void Send_GPS_data(GPS_data GPS_data_parsed); |
Rishin | 12:7debb1c79a06 | 76 | |
Rishin | 12:7debb1c79a06 | 77 | #endif |
Rishin | 12:7debb1c79a06 | 78 |