progress update
This commit is contained in:
		
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							@@ -21,7 +21,7 @@ Follow the directions at [espressif/arduino-esp32](https://github.com/espressif/
 | 
			
		||||
 - [mikalhart/TinyGPSPlus](https://github.com/mikalhart/TinyGPSPlus)
 | 
			
		||||
 - [ThingPulse/esp8266-oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306)
 | 
			
		||||
 | 
			
		||||
#### TTN Decoder
 | 
			
		||||
#### TTN Payload Decoder
 | 
			
		||||
 | 
			
		||||
```C
 | 
			
		||||
function Decoder(bytes, port) {
 | 
			
		||||
@@ -29,22 +29,17 @@ function Decoder(bytes, port) {
 | 
			
		||||
 | 
			
		||||
    decoded.latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
 | 
			
		||||
    decoded.latitude = (decoded.latitude / 16777215.0 * 180) - 90;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
 | 
			
		||||
    decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
 | 
			
		||||
    var sign = bytes[6] & (1 << 7);
 | 
			
		||||
    if(sign)
 | 
			
		||||
    {
 | 
			
		||||
        decoded.altitude = 0xFFFF0000 | altValue;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        decoded.altitude = altValue;
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
    if(sign) decoded.altitude = 0xFFFF0000 | altValue;
 | 
			
		||||
    else decoded.altitude = altValue;
 | 
			
		||||
 | 
			
		||||
    decoded.hdop = bytes[8] / 10.0;
 | 
			
		||||
    decoded.sats = bytes[9] / 10.0;
 | 
			
		||||
 | 
			
		||||
    return decoded;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,14 @@ void ttn_register(void (*callback)(uint8_t message));
 | 
			
		||||
// Configuration
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// Select which T-Beam board is being used. Only uncomment one.
 | 
			
		||||
#define T_BEAM_V07  // AKA Rev0 (first board released)
 | 
			
		||||
// #define T_BEAM_V10  // AKA Rev1 (second board released)
 | 
			
		||||
 | 
			
		||||
// Select the payload format. Change on TTN as well. Only uncomment one.
 | 
			
		||||
#define PAYLOAD_USE_FULL
 | 
			
		||||
//#define PAYLOAD_USE_CAYENNE
 | 
			
		||||
 | 
			
		||||
#define DEBUG_PORT              Serial      // Serial debug port
 | 
			
		||||
#define SERIAL_BAUD             115200      // Serial debug baud rate
 | 
			
		||||
#define SLEEP_BETWEEN_MESSAGES  0           // Do sleep between messages
 | 
			
		||||
@@ -51,10 +59,6 @@ void ttn_register(void (*callback)(uint8_t message));
 | 
			
		||||
#define LORAWAN_ADR             0           // Enable ADR
 | 
			
		||||
#define GPS_WAIT_FOR_LOCK       5000        // Wait 5s after every boot for GPS lock
 | 
			
		||||
 | 
			
		||||
// Only enable one payload format. Change on TTN as well.
 | 
			
		||||
#define PAYLOAD_USE_FULL
 | 
			
		||||
//#define PAYLOAD_USE_CAYENNE
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// DEBUG
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
@@ -94,11 +98,17 @@ void ttn_register(void (*callback)(uint8_t message));
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
#define GPS_SERIAL_NUM  1
 | 
			
		||||
#define GPS_RX_PIN      12
 | 
			
		||||
#define GPS_TX_PIN      15
 | 
			
		||||
#define GPS_BAUDRATE    9600
 | 
			
		||||
#define USE_GPS         1
 | 
			
		||||
 | 
			
		||||
#if defined(T_BEAM_V07)
 | 
			
		||||
#define GPS_RX_PIN 12
 | 
			
		||||
#define GPS_TX_PIN 15
 | 
			
		||||
#elif defined(T_BEAM_V10)
 | 
			
		||||
#define GPS_RX_PIN 34
 | 
			
		||||
#define GPS_TX_PIN 12
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// LoRa SPI
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
@@ -111,3 +121,12 @@ void ttn_register(void (*callback)(uint8_t message));
 | 
			
		||||
#define DIO0_GPIO       26
 | 
			
		||||
#define DIO1_GPIO       33
 | 
			
		||||
#define DIO2_GPIO       32
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// Rev1-specific options
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
#if defined(T_BEAM_V10)
 | 
			
		||||
#define GPS_POWER_CTRL_CH  3
 | 
			
		||||
#define LORA_POWER_CTRL_CH 2
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								main/gps.ino
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								main/gps.ino
									
									
									
									
									
								
							@@ -63,9 +63,10 @@ static void gps_loop() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef PAYLOAD_USE_FULL
 | 
			
		||||
#if defined(PAYLOAD_USE_FULL)
 | 
			
		||||
 | 
			
		||||
    // More data than PAYLOAD_USE_CAYENNE
 | 
			
		||||
    void buildPacket(uint8_t txBuffer[9])
 | 
			
		||||
    void buildPacket(uint8_t txBuffer[10])
 | 
			
		||||
    {
 | 
			
		||||
        LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
 | 
			
		||||
        LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
 | 
			
		||||
@@ -83,12 +84,14 @@ static void gps_loop() {
 | 
			
		||||
        altitudeGps = _gps.altitude.meters();
 | 
			
		||||
        txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
 | 
			
		||||
        txBuffer[7] = altitudeGps & 0xFF;
 | 
			
		||||
        hdopGps = _gps.hdop.value()/10;
 | 
			
		||||
        hdopGps = _gps.hdop.value() / 10;
 | 
			
		||||
        txBuffer[8] = hdopGps & 0xFF;
 | 
			
		||||
        sats = _gps.satellites.value() / 10;
 | 
			
		||||
        txBuffer[9] = sats & 0xFF;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef PAYLOAD_USE_CAYENNE
 | 
			
		||||
#elif defined(PAYLOAD_USE_CAYENNE)
 | 
			
		||||
 | 
			
		||||
    // CAYENNE DF
 | 
			
		||||
    void buildPacket(uint8_t txBuffer[11])
 | 
			
		||||
    {
 | 
			
		||||
@@ -112,4 +115,5 @@ static void gps_loop() {
 | 
			
		||||
        txBuffer[9] = alt >> 8;
 | 
			
		||||
        txBuffer[10] = alt;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -31,11 +31,10 @@ RTC_DATA_ATTR uint32_t count = 0;
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
#include <TinyGPS++.h>
 | 
			
		||||
 | 
			
		||||
#ifdef PAYLOAD_USE_FULL
 | 
			
		||||
  uint8_t txBuffer[9];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef PAYLOAD_USE_CAYENNE
 | 
			
		||||
#if defined(PAYLOAD_USE_FULL)
 | 
			
		||||
  // includes number of satellites and accuracy
 | 
			
		||||
  uint8_t txBuffer[10];
 | 
			
		||||
#elif defined(PAYLOAD_USE_CAYENNE)
 | 
			
		||||
  // CAYENNE DF
 | 
			
		||||
  static uint8_t txBuffer[11] = {0x03, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user