Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "heltec.h"
- //long lastReceiveTime = 0;
- unsigned int counter = 0;
- float snr = 0;
- String nema;
- short rssi;
- short packSize;
- String packet;
- double latconv = 0;
- double longconv = 0;
- float dirtylong = 0;
- float dirtylat = 0;
- void setup(){
- Heltec.begin(true /*DisplayEnable Enable*/, true /*LoRa Enable*/, true /*Serial Enable*/, true /*LoRa use PABOOST*/, 868E6 /*LoRa RF working band*/);
- LoRa.setSpreadingFactor(12);
- LoRa.onReceive(onReceive);
- LoRa.receive();
- }
- void loop(){
- delay(1000);
- LoRa.receive();
- displaySendReceive();
- }
- void displaySendReceive()
- {
- Heltec.display -> drawString(0, 0, "Received Size " + String(packSize));
- Heltec.display -> drawString(0, 10, String(latconv,10));
- Heltec.display -> drawString(0, 20, String(longconv,10));
- Heltec.display -> drawString(0, 40, "RSSI" + String(rssi) + "db " + " SNR " + String(snr, 2));
- Heltec.display -> drawString(0, 50, "Counter: " + (String)(counter-1));
- Heltec.display -> display();
- Heltec.display -> clear();
- }
- void onReceive(int packetSize){
- packet = "";
- packSize = packetSize;
- while (LoRa.available()){
- packet += (char) LoRa.read();
- }
- snr = LoRa.packetSnr();
- rssi = LoRa.packetRssi();
- convert();
- counter++;
- makestring();
- }
- void convert(){
- short degLo = 0;
- short degLat =0;
- double minLat = 0;
- double minLo = 0;
- unsigned long latitude = 0;
- unsigned long longitude = 0;
- latitude = uint8_t(packet[0])*65536 + uint8_t(packet[1])*256 + uint8_t(packet[2]);
- latconv = (latitude / 93206.75) - 90;
- degLat = latconv;
- minLat = (latconv - degLat)*60;
- dirtylat = (degLat*100) + minLat;
- longitude = uint8_t(packet[3])*65536 + uint8_t(packet[4])*256 + uint8_t(packet[5]);
- longconv = (longitude / 46603.375) - 180;
- degLo = longconv;
- minLo = (longconv - degLo)*60;
- dirtylong = (degLo*100) + minLo;
- }
- void makestring(){
- char toSend[90];
- int Time = 0; //time, what is time
- int ndx=0;
- char lat[9];
- char lon[11];
- // dtostrf(altf, 1, 1, alt); //skipping that for now
- dtostrf(dirtylat, 1, 6, lat);
- dtostrf(dirtylong, 1, 5, lon);
- toSend[ndx++] = '§';
- toSend[ndx++] = 'G';
- toSend[ndx++] = 'P';
- toSend[ndx++] = 'G';
- toSend[ndx++] = 'G';
- toSend[ndx++] = 'A';
- toSend[ndx++] = ',';
- short hours = Time/3600; //all that time bollocks
- if(hours>9){
- toSend[ndx++] = '0' +(hours/10);
- toSend[ndx++] = '0' +(hours%10);
- }
- else{
- toSend[ndx++] = '0';
- toSend[ndx++] = '0' + hours;
- }
- short minutes = (Time%3600)/60;
- if(minutes>9){
- toSend[ndx++] = '0' +(minutes/10);
- toSend[ndx++] = '0' +(minutes%10);
- }
- else{
- toSend[ndx++] = '0';
- toSend[ndx++] = '0' + minutes;
- }
- short seconds = (Time%60);
- if(seconds>9){
- toSend[ndx++] = '0' +(seconds/10);
- toSend[ndx++] = '0' +(seconds%10);
- }
- else{
- toSend[ndx++] = '0';
- toSend[ndx++] = '0' + seconds;
- }
- toSend[ndx++]='.';
- for(int i = 0;i<2;i++){
- toSend[ndx++] = '0';
- }
- toSend[ndx++]= ',';
- if(dirtylat<1000){ //latitude: first see if we need to add a zero
- toSend[ndx++] = '0';
- }
- if(dirtylat<100){ //and maybe another
- toSend[ndx++] = '0';
- }
- if(dirtylat<10){ //while we are at it..
- toSend[ndx++] = '0';
- }
- for(int i = 0;i<8;i++){
- toSend[ndx++] = lat[i];
- }
- toSend[ndx++] = ',';
- toSend[ndx++] = 'N'; //I'm gonna hardcode north because lazy
- toSend[ndx++] = ',';
- if(dirtylong<10000){ //same for long
- toSend[ndx++] = '0';
- }
- if(dirtylong<1000){
- toSend[ndx++] = '0';
- }
- if(dirtylong<100){
- toSend[ndx++] = '0';
- }
- if(dirtylong<10){
- toSend[ndx++] = '0';
- }
- for(int i = 0; i<10; i++){
- if(lon[i]!=NULL){
- toSend[ndx++] = lon[i];
- }
- }
- toSend[ndx++] = ',';
- toSend[ndx++] = 'E'; //hardcoded as well
- toSend[ndx++] = ',';
- toSend[ndx++] = '1';
- toSend[ndx++] = ',';
- toSend[ndx++] = '5'; //next up is the number of satellites, anything between 4 and 10 willl do
- toSend[ndx++] = ',';
- toSend[ndx++] = '1'; //now we send the relative accuracy. 1.5 is common
- toSend[ndx++] = '.';
- toSend[ndx++]= '5';
- toSend[ndx++]= ',';
- //for(int i = 0; i<10;i++){ //heres this biggie. the altitude in meters
- // if(alt[i]!=NULL){
- // toSend[ndx++] = alt[i];
- // }
- //}
- /* toSend[ndx++] = '2'; // jk, I'm gonna hardcode that as well
- toSend[ndx++] = '0';
- toSend[ndx++] = '.';
- toSend[ndx++] = '0';
- toSend[ndx++] = '0';
- toSend[ndx++] = ',';
- toSend[ndx++] = 'M';
- toSend[ndx++] = ',';
- toSend[ndx++] = '-'; //next up is the altitude above elisoidal. -34.2 seems to be the standard.
- toSend[ndx++] = '3';
- toSend[ndx++] = '4';
- toSend[ndx++] = '.';
- toSend[ndx++] = '2';
- toSend[ndx++] = ',';
- toSend[ndx++] = 'M';
- toSend[ndx++] = ',';
- toSend[ndx++] = '0';
- toSend[ndx++] = '.';
- toSend[ndx++] = '1';
- toSend[ndx++] = ',';
- for(int i = ndx; i<90;i++){ //remove empty chars
- toSend[i] = NULL;
- }
- */
- Serial.println(toSend);
- /*
- makeCheck(toSend, ndx); //do checksum
- ndx+=3;
- toSend[ndx] = '\0';
- */
- // nema = String(toSend);
- }
- 08:09:40.486 -> Core 1 register dump:
- 08:09:40.486 -> PC : 0x400d1340 PS : 0x00060231 A0 : 0x800d1554 A1 : 0x3ffbe770
- 08:09:40.486 -> A2 : 0x3ffc128c A3 : 0x00000001 A4 : 0x3ffbfea8 A5 : 0x00000000
- 08:09:40.486 -> A6 : 0x3ffbff38 A7 : 0x3ffb0060 A8 : 0xffffffa7 A9 : 0x3ffbe7f0
- 08:09:40.520 -> A10 : 0x3ffbe847 A11 : 0x3ffbe851 A12 : 0x00000001 A13 : 0x00000005
- 08:09:40.520 -> A14 : 0x0000002e A15 : 0x00000000 SAR : 0x00000014 EXCCAUSE: 0x00000004
- 08:09:40.520 -> EXCVADDR: 0x00000000 LBEG : 0x400029ac LEND : 0x400029cb LCOUNT : 0x00000000
- 08:09:40.520 -> Core 1 was running in ISR context:
- 08:09:40.520 -> EPC1 : 0x400d1340 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40082cc7
- 08:09:40.553 ->
- 08:09:40.553 -> ELF file SHA256: 0000000000000000
- 08:09:40.553 ->
- 08:09:40.553 -> Backtrace: 0x400d1340:0x3ffbe770 0x400d1551:0x3ffbe8d0 0x400d20f4:0x3ffbe8f0 0x400d210a:0x3ffbe910 0x40080f5d:0x3ffbe930 0x40081ec1:0x3ffbe950 0x400ed303:0x3ffbc650 0x400d8757:0x3ffbc670 0x400881c6:0x3ffbc690 0x400863c5:0x3ffbc6b0
- PC: 0x400d1340: makestring() at C:\Users\chaos\Documents\Arduino\gps_receiver/gps_receiver.ino line 129
- EXCVADDR: 0x00000000
- Decoding stack results
- 0x400d1340: makestring() at C:\Users\chaos\Documents\Arduino\gps_receiver/gps_receiver.ino line 129
- 0x400d1551: onReceive(int) at C:\Users\chaos\Documents\Arduino\gps_receiver/gps_receiver.ino line 52
- 0x400d20f4: LoRaClass::handleDio0Rise() at C:\Users\chaos\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src\lora\LoRa.cpp line 518
- 0x400d210a: LoRaClass::onDio0Rise() at C:\Users\chaos\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src\lora\LoRa.cpp line 548
- 0x40080f5d: __onPinInterrupt at C:\Users\chaos\Documents\Arduino\hardware\heltec\esp32\cores\esp32\esp32-hal-gpio.c line 220
- 0x400ed303: esp_pm_impl_waiti at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/pm_esp32.c line 492
- 0x400d8757: esp_vApplicationIdleHook at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/freertos_hooks.c line 63
- 0x400881c6: prvIdleTask at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/tasks.c line 3382
- 0x400863c5: vPortTaskWrapper at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/port.c line 143
Add Comment
Please, Sign In to add comment