Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LoRaWAN-lib SingleFrequencyLora
Fork of Lora_with_GPS by
Revision 14:6990bc2f44e9, committed 2017-11-22
- Comitter:
- Rishin
- Date:
- Wed Nov 22 21:01:30 2017 +0000
- Parent:
- 13:ac84e36985a7
- Commit message:
- still crashing - finding the root cause
Changed in this revision
--- a/app/l86.cpp Mon Nov 20 12:09:24 2017 +0000
+++ b/app/l86.cpp Wed Nov 22 21:01:30 2017 +0000
@@ -97,7 +97,7 @@
strcpy(GPS_parsed.Speed_Over_Ground,"0.00");
strcpy(GPS_parsed.Course_Over_Ground,"000.00");
strcpy(GPS_parsed.Date,"000000");
- strcpy(GPS_parsed.Valid,"V");
+ strcpy(GPS_parsed.Valid,RMC_parsed.Status);
}
return GPS_parsed;
}
@@ -114,32 +114,31 @@
}
/* Send GPS data using LoRa module */
-void Send_GPS_data(GPS_data GPS_data_parsed){
- __disable_irq();
+void Send_GPS_data(GPS_data GPS_data_parsed, McpsReq_t *mcpsReqs){//, char *NodeID, char Boat_type){
char AppData[APPDATA_SIZE];
- // Could do this using a pointer and pointing to the first address of the struct?
+ // Could do this using a pointer and pointing to the address of the struct?
// fill AppData byte array with GPS_data struct
- strcat(AppData, GPS_data_parsed.UTC_Time);
+ // strcat(AppData, NodeID);
+ // strcat(AppData, ",");
+ // strcat(AppData, Boat_type);
+ // strcat(AppData, ",");
strcat(AppData, GPS_data_parsed.Latitude);
+ strcat(AppData, ",");
strcat(AppData, GPS_data_parsed.Longitude);
+ strcat(AppData, ",");
+ strcat(AppData, GPS_data_parsed.Course_Over_Ground);
+ strcat(AppData, ",");
strcat(AppData, GPS_data_parsed.Speed_Over_Ground);
- strcat(AppData, GPS_data_parsed.Course_Over_Ground);
+ strcat(AppData, ",");
strcat(AppData, GPS_data_parsed.Date);
+ strcat(AppData, ",");
+ strcat(AppData, GPS_data_parsed.UTC_Time);
+ strcat(AppData, ",");
strcat(AppData, GPS_data_parsed.Valid);
- //pc2.printf(AppData);
- //Sendframe
-
- McpsReq_t mcpsReq;
-
- uint8_t AppPort = 3;
- mcpsReq.Type = MCPS_UNCONFIRMED;
- mcpsReq.Req.Unconfirmed.fPort = AppPort;
- mcpsReq.Req.Unconfirmed.fBuffer = AppData;
- mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE;
- mcpsReq.Req.Unconfirmed.Datarate = DR_5;
-
- LoRaMacMcpsRequest( &mcpsReq );
- __enable_irq();
+ //Sendframe
+
+ // LoRaMacMcpsRequest( &mcpsReq );
+ //memset(&AppData[0], 0, sizeof(AppData));
}
--- a/app/l86.hpp Mon Nov 20 12:09:24 2017 +0000
+++ b/app/l86.hpp Wed Nov 22 21:01:30 2017 +0000
@@ -36,7 +36,7 @@
// Pull Force_on high to exit backup mode
/* Size of packet being transmitted over LoRa */
-#define APPDATA_SIZE 49
+#define APPDATA_SIZE 55
static const char GPRMC_Tag[] = "$GPRMC";
static const char GNRMC_Tag[] = "$GNRMC";
--- a/app/main.cpp Mon Nov 20 12:09:24 2017 +0000
+++ b/app/main.cpp Wed Nov 22 21:01:30 2017 +0000
@@ -18,6 +18,7 @@
#include "LoRaMac.h"
#include "l86.hpp"
+
// #define APPDATA_SIZE 55 // size of a GPS_data struct //commented by Rish
#define LORAWAN_DEFAULT_DATARATE DR_0
#define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x01234567
@@ -40,6 +41,7 @@
volatile int Char_index = 0; // index for char array
char Rx_data[MAX_NMEA_LENGTH] = "0"; // char array to store received bytes
char tx_line[82];
+volatile uint8_t Transmission_in_progress = 0;
void gps_receive(void) {
// Note: you need to actually read from the serial to clear the RX interrupt
@@ -49,34 +51,33 @@
// pc.putc(incoming);
// #endif
Rx_data[Char_index] = incoming;
-
- if((Rx_data[Char_index] == '\n')){ // Received the end of an NMEA scentence
- if((strncmp(GPRMC_Tag,Rx_data,(sizeof(GPRMC_Tag)-1)) == 0) || (strncmp(GNRMC_Tag,Rx_data,(sizeof(GNRMC_Tag)-1)) == 0)){
- RMC = Parse_RMC_sentence(Rx_data);
- if(strcmp(RMC.Status, "A") == 0){
- GPS_status = 0; // Turn status LED off
- // GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software)
- // Call function to send using LoRa module
- }
- else{
- GPS_status = 1;
- // Send "No GPS fix" over LoRa?
+ if(Rx_data[Char_index] == '$'){
+ Transmission_in_progress = 1;
+ }
+ if(Transmission_in_progress == 1){
+ if((Rx_data[Char_index] == '\n')){ // Received the end of an NMEA scentence
+ if((strncmp(GPRMC_Tag,Rx_data,(sizeof(GPRMC_Tag)-1)) == 0) || (strncmp(GNRMC_Tag,Rx_data,(sizeof(GNRMC_Tag)-1)) == 0)){
+ RMC = Parse_RMC_sentence(Rx_data);
+ if(strcmp(RMC.Status, "A") == 0){
+ GPS_status = 0; // Turn status LED off
+ }
+ else{
+ //GPS_status = 1;
+ }
+ GPS_status = !GPS_status; // for debugging
+ NVIC_DisableIRQ(USART1_IRQn);
+ GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software)
+ // Send_GPS_data(GPS_parse); // This doesn't work with LoRa send code but works without :/
+ NVIC_EnableIRQ(USART1_IRQn);
}
-
- // delete this line // Or replace with whatever Tom wants for invalid GPS data
- GPS_parse = Parse_RMC_data(RMC); // Parse into format suitable for Tom (Dinghy_RaceTrak software)
- // __disable_irq(); // edit
- // Send_GPS_data(GPS_parse); //edit
-
-
+ Transmission_in_progress = 0;
+ Char_index = 0;
+ memset(Rx_data,0,sizeof(Rx_data));
}
- Char_index = 0;
- memset(Rx_data,0,sizeof(Rx_data));
+ else
+ Char_index++;
}
- else
- Char_index++;
}
- // __enable_irq();// edit
return;
// store chars into a string then process into LAT, LONG, SOG, COG & DATETIME, VALID/INVLAID
}
@@ -102,8 +103,7 @@
int main( void )
{
//Initialise firmware
-
-
+
LoRaMacPrimitives_t LoRaMacPrimitives;
LoRaMacCallback_t LoRaMacCallbacks;
MibRequestConfirm_t mibReq;
@@ -163,7 +163,7 @@
//Sendframe
- /*McpsReq_t mcpsReq;
+ /*McpsReq_t mcpsReq; // Commented out by Rish
uint8_t AppPort = 3;
mcpsReq.Type = MCPS_UNCONFIRMED;
@@ -172,7 +172,7 @@
mcpsReq.Req.Unconfirmed.fBufferSize = APPDATA_SIZE;
mcpsReq.Req.Unconfirmed.Datarate = DR_5;
- LoRaMacMcpsRequest( &mcpsReq ); // Commented out by Rish*/
+ //LoRaMacMcpsRequest( &mcpsReq );*/ // Commented out by Rish
GPS_status = 1;
gps.attach(&gps_receive, Serial::RxIrq);
@@ -180,13 +180,13 @@
gps.printf(PMTK_SET_UPDATE_F_2HZ); // Set update Frequency to 2Hz
while(1){
- wait(5); // could time how long the IRQ takes to improve the efficienct of this
+ wait(3);
//LoRaMacMcpsRequest( &mcpsReq );
// Print_GPS_data(GPS_parse);
+ while(Transmission_in_progress==1);
+ NVIC_DisableIRQ(USART1_IRQn);
Send_GPS_data(GPS_parse);
-
- //interrupt is not getting triggered!- reentrancy issues
- //gps_receive();
+ NVIC_EnableIRQ(USART1_IRQn);
}
}
