kopia lustrzana https://github.com/Max-Plastix/tbeam-helium-mapper
Updates to distance-based T-Beam mapper
Modifications by Max-Plastix - DevEUI is auto-generated per-device - Print all three ID values to console at boot, in a format that pastes into Helium Console. - Change Payload to #2 and match CubeCell Mapper format, including battery voltage. (Shared decoder with CubeCell)pull/1/head
rodzic
ff421944c9
commit
a9f5a6fc95
|
@ -32,8 +32,8 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||
// Version
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define APP_NAME "Helium TTGO"
|
||||
#define APP_VERSION "1.1-tm"
|
||||
#define APP_NAME "Helium TTGO Distance"
|
||||
#define APP_VERSION "1.1-tm-mp"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Configuration
|
||||
|
@ -44,8 +44,9 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||
#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 PAYLOAD_USE_FULL
|
||||
// #define PAYLOAD_USE_CAYENNE
|
||||
#define PAYLOAD_USE_MAPPER
|
||||
|
||||
// If using a single-channel gateway, uncomment this next option and set to your gateway's channel
|
||||
//#define SINGLE_CHANNEL_GATEWAY 0
|
||||
|
@ -54,7 +55,7 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||
#define ALWAYS_SHOW_LOGO
|
||||
|
||||
//Uncomment to enable discarding network settings by long pressing second button
|
||||
//#define PREFS_DISCARD
|
||||
#define PREFS_DISCARD
|
||||
|
||||
// If you are having difficulty sending messages to TTN after the first successful send,
|
||||
// uncomment the next option and experiment with values (~ 1 - 5)
|
||||
|
@ -66,14 +67,14 @@ void ttn_register(void (*callback)(uint8_t message));
|
|||
#define SEND_INTERVAL (20 * 1000) // Sleep for these many millis
|
||||
#define MESSAGE_TO_SLEEP_DELAY 5000 // Time after message before going to sleep
|
||||
#define LOGO_DELAY 5000 // Time to show logo on first boot
|
||||
#define LORAWAN_PORT 10 // Port the messages will be sent to
|
||||
#define LORAWAN_PORT 2 // Port the messages will be sent to
|
||||
#define LORAWAN_CONFIRMED_EVERY 0 // Send confirmed message every these many messages (0 means never)
|
||||
#define LORAWAN_SF DR_SF7 // Spreading factor (recommended DR_SF7 for ttn network map purposes, DR_SF10 works for slow moving trackers)
|
||||
#define LORAWAN_SF DR_SF7 // Spreading factor (recommended DR_SF7 for ttn network map purposes, DR_SF10 works for slow moving trackers)
|
||||
#define LORAWAN_ADR 0 // Enable ADR
|
||||
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
||||
|
||||
// If not defined, we will wait for lock forever
|
||||
#define GPS_WAIT_FOR_LOCK (60 * 1000) // Wait after every boot for GPS lock (may need longer than 5s because we turned the gps off during deep sleep)
|
||||
//#define GPS_WAIT_FOR_LOCK (60 * 1000) // Wait after every boot for GPS lock (may need longer than 5s because we turned the gps off during deep sleep)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// LoRa send criteria
|
||||
|
|
|
@ -28,16 +28,16 @@ Credentials file
|
|||
// first. When copying an EUI from ttnctl output, this means to reverse
|
||||
// the bytes. For TTN issued EUIs the last bytes should be 0x00, 0x00,
|
||||
// 0x00.
|
||||
static const u1_t PROGMEM APPEUI[8] = { 0x4D, 0x9C, 0x1B, 0xE3, 0xD5, 0x15, 0xD8, 0xC1 };
|
||||
static const u1_t PROGMEM APPEUI[8] = { 0xA0, 0x2E, 0x8E, 0x90, 0xBF, 0xF9, 0x81, 0x60 }; // Reverse Helium Console
|
||||
|
||||
// This should also be in little endian format (lsb), see above.
|
||||
// Note: You do not need to set this field, if unset it will be generated automatically based on the device macaddr
|
||||
static u1_t DEVEUI[8] = { 0x64, 0x3F, 0xE9, 0x85, 0x43, 0xFC, 0x0D, 0xAC };
|
||||
// Note: If all values are zero, the DevEUI will be generated automatically based on the device macaddr
|
||||
static u1_t DEVEUI[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
// This key should be in big endian format (msb) (or, since it is not really a
|
||||
// number but a block of memory, endianness does not really apply). In
|
||||
// practice, a key taken from ttnctl can be copied as-is.
|
||||
// The key shown here is the semtech default key.
|
||||
static const u1_t PROGMEM APPKEY[16] = { 0xC2, 0x5D, 0x64, 0xE7, 0xE9, 0x7F, 0x85, 0xCE, 0x09, 0x63, 0x20, 0xE8, 0x4F, 0x82, 0xAD, 0x76 };
|
||||
|
||||
static const u1_t PROGMEM APPKEY[16] = { 0xCF, 0x4B, 0x3E, 0x8F, 0x8F, 0xCB, 0x77, 0x9C, 0x8E, 0x1C, 0xAE, 0xE3, 0x11, 0x71, 0x2A, 0xE5 };
|
||||
|
||||
#endif
|
||||
|
|
39
main/gps.ino
39
main/gps.ino
|
@ -69,7 +69,44 @@ static void gps_loop() {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(PAYLOAD_USE_FULL)
|
||||
|
||||
#if defined(PAYLOAD_USE_MAPPER)
|
||||
// Same format as CubeCell mappers
|
||||
void buildPacket(uint8_t txBuffer[11]) {
|
||||
int speed;
|
||||
LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
|
||||
LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
|
||||
altitudeGps = _gps.altitude.meters();
|
||||
// hdopGps = _gps.hdop.value() / 10;
|
||||
sats = _gps.satellites.value();
|
||||
speed = (uint16_t)_gps.speed.kmph(); // convert from float
|
||||
|
||||
sprintf(t, "Lat: %f", _gps.location.lat());
|
||||
Serial.println(t);
|
||||
sprintf(t, "Lng: %f", _gps.location.lng());
|
||||
Serial.println(t);
|
||||
sprintf(t, "Alt: %d", altitudeGps);
|
||||
Serial.println(t);
|
||||
sprintf(t, "Hdop: %d", hdopGps);
|
||||
Serial.println(t);
|
||||
sprintf(t, "Sats: %d", sats);
|
||||
Serial.println(t);
|
||||
|
||||
txBuffer[0] = (LatitudeBinary >> 16) & 0xFF;
|
||||
txBuffer[1] = (LatitudeBinary >> 8) & 0xFF;
|
||||
txBuffer[2] = LatitudeBinary & 0xFF;
|
||||
txBuffer[3] = (LongitudeBinary >> 16) & 0xFF;
|
||||
txBuffer[4] = (LongitudeBinary >> 8) & 0xFF;
|
||||
txBuffer[5] = LongitudeBinary & 0xFF;
|
||||
txBuffer[6] = (altitudeGps >> 8) & 0xFF;
|
||||
txBuffer[7] = altitudeGps & 0xFF;
|
||||
txBuffer[8] = ((unsigned char *)(&speed))[0];
|
||||
uint16_t batteryVoltage = ((float_t)((float_t)(axp.getBattVoltage()) / 10.0) + .5);
|
||||
txBuffer[9] = (uint8_t)((batteryVoltage - 200) & 0xFF);
|
||||
txBuffer[10] = sats & 0xFF;
|
||||
}
|
||||
|
||||
#elif defined(PAYLOAD_USE_FULL)
|
||||
|
||||
// More data than PAYLOAD_USE_CAYENNE
|
||||
void buildPacket(uint8_t txBuffer[10])
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
- Changed Text output to reflect Helium, and not TTL (Code referances ttn, just to prevent brakes in this awesome code)
|
||||
- Changed credentials file to use OTAA by default.
|
||||
- Changed GPS metric output text "Error", to "Accuracy/HDOP".
|
||||
|
||||
*/
|
||||
/*
|
||||
Modifications by Max-Plastic
|
||||
- DevEUI is auto-generated per-device
|
||||
- Print all three ID values to console at boot, in a format that pastes into Helium Console.
|
||||
- Change Payload to 2 and match CubeCell Mapper format, including battery voltage.
|
||||
/*
|
||||
|
||||
Main module
|
||||
|
@ -67,6 +71,8 @@ static 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};
|
||||
#elif defined (PAYLOAD_USE_MAPPER)
|
||||
static uint8_t txBuffer[11];
|
||||
#endif
|
||||
|
||||
// deep sleep support
|
||||
|
|
|
@ -42,9 +42,8 @@ void _screen_header() {
|
|||
display->drawString(0, 2, buffer);
|
||||
|
||||
// Datetime (if the axp192 PMIC is present, alternate between powerstats and time)
|
||||
if(axp192_found && millis()%8000 < 3000){
|
||||
if(axp192_found && millis()%5000 < 4000){
|
||||
snprintf(buffer, sizeof(buffer), "%.1fV %.0fmA", axp.getBattVoltage()/1000, axp.getBattChargeCurrent() - axp.getBattDischargeCurrent());
|
||||
|
||||
} else {
|
||||
gps_time(buffer, sizeof(buffer));
|
||||
}
|
||||
|
@ -98,7 +97,7 @@ void screen_print(const char * text, uint8_t x, uint8_t y) {
|
|||
}
|
||||
|
||||
void screen_print(const char * text) {
|
||||
Serial.printf("Screen: %s\n", text);
|
||||
Serial.printf("Screen: %s", text);
|
||||
if(!display) return;
|
||||
|
||||
display->print(text);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
27
main/ttn.ino
27
main/ttn.ino
|
@ -117,7 +117,7 @@ static void printHex2(unsigned v) {
|
|||
}
|
||||
|
||||
#ifdef USE_OTAA
|
||||
// generate DevEUI from macaddr if needed
|
||||
// generate DevEUI from macaddr if it's all zero
|
||||
void initDevEUI() {
|
||||
bool needInit = true;
|
||||
for(int i = 0; i < sizeof(DEVEUI); i++)
|
||||
|
@ -125,14 +125,6 @@ void initDevEUI() {
|
|||
|
||||
if(needInit)
|
||||
gen_lora_deveui(DEVEUI);
|
||||
|
||||
Serial.print("\n\nDevEUI: ");
|
||||
for(int i = 0; i < sizeof(DEVEUI); i++) {
|
||||
if (i != 0)
|
||||
Serial.print("-");
|
||||
printHex2(DEVEUI[i]);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -244,6 +236,23 @@ bool ttn_setup() {
|
|||
initDevEUI();
|
||||
#endif
|
||||
|
||||
// Print out DevEUI, AppEUI, APPKEY suitable for Helium Console
|
||||
Serial.println();
|
||||
Serial.print("DevEUI (msb): ");
|
||||
for (int i = 0; i < sizeof(DEVEUI); i++)
|
||||
printHex2(DEVEUI[sizeof(DEVEUI) - 1 - i]);
|
||||
Serial.println();
|
||||
|
||||
Serial.print("APPEUI (msb): ");
|
||||
for (int i = 0; i < sizeof(APPEUI); i++)
|
||||
printHex2(APPEUI[sizeof(APPEUI) - 1 - i]);
|
||||
Serial.println();
|
||||
|
||||
Serial.print("APPKEY (msb): ");
|
||||
for (int i = 0; i < sizeof(APPKEY); i++)
|
||||
printHex2(APPKEY[i]);
|
||||
Serial.println();
|
||||
|
||||
// SPI interface
|
||||
SPI.begin(SCK_GPIO, MISO_GPIO, MOSI_GPIO, NSS_GPIO);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue