Lorawan to Pulga with GPS
Dependencies: pulga-lorawan-drv Si1133 BME280
Diff: main.cpp
- Revision:
- 61:225d19b4b0a9
- Parent:
- 60:c4f9e9202fb4
diff -r c4f9e9202fb4 -r 225d19b4b0a9 main.cpp --- a/main.cpp Mon Nov 30 19:25:11 2020 +0000 +++ b/main.cpp Thu Jan 07 13:46:09 2021 +0000 @@ -31,7 +31,7 @@ // Max payload size can be LORAMAC_PHY_MAXPAYLOAD. // This example only communicates with much shorter messages (<30 bytes). // If longer messages are used, these buffers must be changed accordingly. -uint8_t tx_buffer[30]; +uint8_t tx_buffer[256]; uint8_t rx_buffer[30]; /* @@ -102,9 +102,31 @@ mbed::DigitalOut _alive_led(P1_13, 0); mbed::DigitalOut _actuated_led(P1_14,1); +int lat=0; +int lon=0; +int latitude=0; +int longitude=0; + +#include "gps.txt" + +void GPS_Read(void) +{ + gps_print_local(); + printf ("gps longitude=%d \n",lon); + printf ("gps latitude=%d \n",lat); + if(lat!=0 && lon!=0){ + longitude=lon; + latitude=lat; +// led1 = !led1; + } + } int main(void) { + gps_config(); + gps_leBootMsg(); + gps_config_gnss (); + // setup tracing setup_trace(); @@ -167,8 +189,9 @@ uint16_t packet_len; int16_t retcode; int32_t sensor_value; + gps_print_local(); - packet_len = sprintf((char *) tx_buffer, "Sensor Value is 10.0\n"); + packet_len = sprintf((char *) tx_buffer, "lon = %d and lat = %d\n", lon, lat); retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len, MSG_UNCONFIRMED_FLAG); @@ -186,6 +209,8 @@ return; } + printf ("gps longitude=%d \n",lon); + printf ("gps latitude=%d \n",lat); printf("\r\n %d bytes scheduled for transmission \r\n", retcode); memset(tx_buffer, 0, sizeof(tx_buffer)); }