gps-node-sensor

antoniorrg/sim28-gps-module/gps-node-sensor

No description
gps-node-sensor
@/gps-node-sensor
IN@/sim28-gps-device
Modenumber
UPDpulse
Triggers the node
gps-node-sensor
IN
Mode
UPD
Latitude
Longitude
Longitudenumber
Shows the Longitude of your current position (in degrees units o)
Latitudenumber
Shows the Latitute of your current position (in degrees units o)
To use the node in your project you should have the antoniorrg/sim28-gps-module library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#include <SoftwareSerial.h>

node {
    // Internal state variables defined at this level persists across evaluations
    Number foo;
    uint8_t bar = 5;

    

    void evaluate(Context ctx) {
        bar += 42;

        if (isSettingUp()) {
            // This run once
            foo = (Number)(bar + 1);
        }

               if (!isInputDirty<input_UPD>(ctx))
       return;

auto SoftSerial = getValue<input_IN>(ctx);
        
uint8_t Cut = 78;
char Data [64];
char Message;
char buffer[64];                   // buffer array for data receive over serial port
int count=0;                                // counter for buffer array
int i, j;
double Val1, Val2;
float Buff;
int count2, count4, count5;
int count3 = 0;
int m = 0;
int y;

y = getValue<input_Mode>(ctx);

        
if (y == 0){
        while(SoftSerial->available())               // reading data into char array
        {
            Message=SoftSerial->read();
            if (Message == 71){ 
            m = 1;
            }
            if (m == 1){
            Data[count] = Message;
            count++;
            }
            if(count == 64)break;
        }

m = 0;
for (i=0; i<64; i++){
Message = Data [i];

Serial.print ("");

if (Message == Cut){
  count2 = 3;
  count3 = 0;
  count4 = 2;
  count5 = 0;
  Val1 = 0;
  Val2 = 0;
  while (count2<12){
if (count2 == 7){
  count2++;
}
if (count4 == 6){
  count4++;
}
Buff = Data [i+count2];
Val1 = Val1 + (Buff-48)*(pow(10, 3 - count3));
Buff = Data [i-count4];
Val2 = Val2 + (Buff-48)*(pow(10, -4 + count5));
count2++;
count3++;
count4++;
count5++;
  }
emitValue<output_Latitude>(ctx, (Val2/100));
emitValue<output_Longitude>(ctx, Val1);

}
}
    // if no data transmission ends, write buffer to hardware serial port
     //Serial.println ();
     for (int i=0; i<64;i++)
    {
      
        Data[i]=NULL;
    }                            // call clearBufferArray function to clear the stored data from the array
        count = 0;                                  // set counter of while loop to zero 
}

if (y == 1){

        while(SoftSerial->available())               // reading data into char array
        {
            Message=SoftSerial->read();
            Data[count] = Message;
            count++;
            if(count == 64)break;
        }

m = 0;
for (i=0; i<64; i++){
Message = Data [i];
Serial.print (Message);


}
    // if no data transmission ends, write buffer to hardware serial port
     //Serial.println ();
     for (int i=0; i<64;i++)
    {
      
        Data[i]=NULL;
    }                            // call clearBufferArray function to clear the stored data from the array
        count = 0;  

}

    }
}