Switched to US915

pull/1/head
Max-Plastix 2021-11-23 09:17:24 -08:00
rodzic ce84c722b3
commit 08cf646944
9 zmienionych plików z 82 dodań i 81 usunięć

Wyświetl plik

@ -70,7 +70,7 @@ Verison: `1.1-tm`
Most mappers usually operate in **time target** mode, where they send data to network every set interval (i.e. `SEND_INTERVAL`). There is however a different use case for fast moving mappers - like in a car at motorway speeds...
This feature allows you to switch mapping mode from time target to distace target and back. You can configure your desierd distance target in `configuration.h` and turn ON/OFF by pressing the `USR` button for over 1sec:
This feature allows you to switch mapping mode from time target to distace target and back. You can configure your desired distance target in `configuration.h` and turn ON/OFF by pressing the `USR` button for over 1sec:
```
#define DISTANCE_TARGET 200.0 // MUST be decimal number; distance target in meters

Wyświetl plik

@ -33,7 +33,7 @@ void ttn_register(void (*callback)(uint8_t message));
// -----------------------------------------------------------------------------
#define APP_NAME "Helium TTGO"
#define APP_VERSION "1.2-tm-mp"
#define APP_VERSION "1.22-tm-mp"
// -----------------------------------------------------------------------------
// Configuration
@ -41,7 +41,7 @@ void ttn_register(void (*callback)(uint8_t message));
// 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)
#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
@ -66,7 +66,7 @@ void ttn_register(void (*callback)(uint8_t message));
#define SLEEP_BETWEEN_MESSAGES false // Do sleep between messages
#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 LOGO_DELAY 3000 // Time to show logo on first boot
#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)
@ -79,9 +79,9 @@ void ttn_register(void (*callback)(uint8_t message));
// -----------------------------------------------------------------------------
// LoRa send criteria
// -----------------------------------------------------------------------------
#define MIN_DIST 50.0 // MUST be decimal number; minimum distance in meters from the last sent location before we can send again. A hex is about 340m, divide by this value to get the pings per hex.
#define STATIONARY_TX_INTERVAL 60 // If stationary the LoRa frame will be sent once every N cycles... with 30sec cycle, interval of 60 means to transmit once every 30min
#define DISTANCE_TARGET 200.0 // MUST be decimal number; distance target in meters
#define MIN_DIST 35.0 // MUST be decimal number; minimum distance in meters from the last sent location before we can send again. A hex is about 340m, divide by this value to get the pings per hex.
#define STATIONARY_TX_INTERVAL 30 // If stationary the LoRa frame will be sent once every N cycles... with 20sec cycle, interval of 30 means to transmit once every 10min
#define DISTANCE_TARGET 100.0 // MUST be decimal number; distance target in meters
// -----------------------------------------------------------------------------

Wyświetl plik

@ -1,43 +1,7 @@
/*
Credentials file
*/
#pragma once
// Only one of these settings must be defined
//#define USE_ABP
#define USE_OTAA
#ifdef USE_ABP
// LoRaWAN NwkSKey, network session key
static const u1_t PROGMEM NWKSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
// LoRaWAN AppSKey, application session key
static const u1_t PROGMEM APPSKEY[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
// LoRaWAN end-device address (DevAddr)
// This has to be unique for every node
static const u4_t DEVADDR = 0x00000000;
#endif
#ifdef USE_OTAA
// This EUI must be in little-endian format, so least-significant-byte (lsb)
// 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] = { 0xA0, 0x2E, 0x8E, 0x90, 0xBF, 0xF9, 0x81, 0x60 }; // Reverse Helium Console
// This should also be in little endian format (lsb), see above.
// 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] = { 0xCF, 0x4B, 0x3E, 0x8F, 0x8F, 0xCB, 0x77, 0x9C, 0x8E, 0x1C, 0xAE, 0xE3, 0x11, 0x71, 0x2A, 0xE5 };
#endif
extern const u1_t PROGMEM APPEUI[8];
extern u1_t DEVEUI[8];
extern const u1_t PROGMEM APPKEY[16];

Wyświetl plik

@ -0,0 +1,20 @@
/*
Credentials definition
*/
#include "credentials.h"
#ifndef USE_OTAA
#error "Only OTAA is supported for Helium!"
#endif
// This EUI must be in little-endian format, so least-significant-byte (lsb)
// first. Note that this is reversed from the order (msb) shown in Helium Console
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).
// Note: If all values are zero, the DevEUI will be generated automatically based on the device macaddr
u1_t DEVEUI[8] = {0, 0, 0, 0, 0, 0, 0, 0};
// This key should be in big endian format (msb) matching the Helium Console
// The key shown here is the semtech default key.
const u1_t PROGMEM APPKEY[16] = {0xCF, 0x4B, 0x3E, 0x8F, 0x8F, 0xCB, 0x77, 0x9C, 0x8E, 0x1C, 0xAE, 0xE3, 0x11, 0x71, 0x2A, 0xE5};

Wyświetl plik

@ -136,6 +136,7 @@ void buildPacket(uint8_t txBuffer[11]) {
txBuffer[5] = LongitudeBinary & 0xFF;
txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
txBuffer[7] = altitudeGps & 0xFF;
txBuffer[8] = hdopGps & 0xFF;
txBuffer[9] = sats & 0xFF;
}

Wyświetl plik

@ -193,7 +193,7 @@ bool trySend() {
}
// update counter
stationaryTickCounter++;
Serial.println("** STATIONARY");
Serial.println("(stationary)");
return false;
}
@ -268,34 +268,40 @@ void sleep() {
void callback(uint8_t message) {
bool ttn_joined = false;
if (EV_JOINED == message) {
ttn_joined = true;
#if 0
{
char buffer[20];
snprintf(buffer, sizeof(buffer), "MSG %d\n", message);
screen_print(buffer);
}
if (EV_JOINING == message) {
if (ttn_joined) {
screen_print("Helium joining...\n");
} else {
screen_print("Joined Helium!\n");
}
}
if (EV_JOIN_FAILED == message) screen_print("Helium join failed\n");
if (EV_REJOIN_FAILED == message) screen_print("Helium rejoin failed\n");
if (EV_RESET == message) screen_print("Reset Helium connection\n");
if (EV_LINK_DEAD == message) screen_print("Helium link dead\n");
if (EV_ACK == message) screen_print("ACK received\n");
if (EV_PENDING == message) screen_print("Message discarded\n");
if (EV_QUEUED == message) screen_print("Message queued\n");
#endif
if (EV_JOIN_TXCOMPLETE == message) Serial.println("# JOIN_TXCOMPLETE");
if (EV_TXCOMPLETE == message) Serial.println("# TXCOMPLETE");
if (EV_RXSTART == message) Serial.println("# RXSTART");
if (EV_TXCANCELED == message) Serial.println("# TXCANCELED");
if (EV_TXSTART == message) Serial.println("# TXSTART");
if (EV_JOINING == message) Serial.println("# JOINING");
if (EV_JOINED == message) Serial.println("# JOINED");
if (EV_JOIN_FAILED == message) Serial.println("# JOIN_FAILED");
if (EV_REJOIN_FAILED == message) Serial.println("# REJOIN_FAILED");
if (EV_RESET == message) Serial.println("# RESET");
if (EV_LINK_DEAD == message) Serial.println("# LINK_DEAD");
if (EV_ACK == message) Serial.println("# ACK");
if (EV_PENDING == message) Serial.println("# PENDING");
if (EV_QUEUED == message) Serial.println("# QUEUED");
if (EV_TXSTART == message) {
screen_print("Sending.. ");
}
// We only want to say 'packetSent' for our packets (not packets needed for joining)
if (EV_TXCOMPLETE == message && packetQueued) {
screen_print("Message sent\n");
screen_print("sent.\n");
packetQueued = false;
packetSent = true;
}
if (EV_RESPONSE == message) {
screen_print("[Helium] Response: ");
size_t len = ttn_response_len();
@ -481,6 +487,7 @@ void setup() {
}
else {
ttn_register(callback);
// ttn_erase_prefs();
ttn_join();
ttn_adr(LORAWAN_ADR);
}
@ -539,9 +546,7 @@ void loop() {
// delay(5000); // Give some time to read the screen
// ESP.restart();
// #endif
} else {
// short press, send beacon
Serial.println("Short press :-P");
justSendNow = true;

Wyświetl plik

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "OLEDDisplay.h"
#include "images.h"
#include "fonts.h"
#include "credentials.h"
#define SCREEN_HEADER_HEIGHT 14
@ -36,18 +37,26 @@ void _screen_header() {
char buffer[20];
// Message count
snprintf(buffer, sizeof(buffer), "#%03d", ttn_get_count() % 1000);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 2, buffer);
// Cycle display every 2 seconds
if (axp192_found && millis() % 4000 < 2000)
{
// 2 bytes of Device EUI with Voltage and Current
snprintf(buffer, sizeof(buffer), "#%04X", ((DEVEUI[7] << 8) | DEVEUI[6]));
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 2, buffer);
snprintf(buffer, sizeof(buffer), "%.1fV %.0fmA", axp.getBattVoltage() / 1000, axp.getBattChargeCurrent() - axp.getBattDischargeCurrent());
}
else
{
// Message count and time
snprintf(buffer, sizeof(buffer), "%4d", ttn_get_count() % 10000);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 2, buffer);
// Datetime (if the axp192 PMIC is present, alternate between powerstats and time)
if(axp192_found && millis()%4000 < 2000){
snprintf(buffer, sizeof(buffer), "%.1fV %.0fmA", axp.getBattVoltage()/1000, axp.getBattChargeCurrent() - axp.getBattDischargeCurrent());
} else {
gps_time(buffer, sizeof(buffer));
}
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(display->getWidth()/2, 2, buffer);

Wyświetl plik

@ -143,7 +143,7 @@ void onEvent(ev_t event) {
LMIC_setLinkCheckMode(0); // Link check problematic if not using ADR. Must be set after join
}
Serial.println(F("EV_JOINED"));
Serial.println(F("! EV_JOINED as:"));
u4_t netid = 0;
devaddr_t devaddr = 0;
@ -179,9 +179,9 @@ void onEvent(ev_t event) {
}
break; }
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (inc. RX win. wait)"));
Serial.println(F("! EV_TXCOMPLETE"));
if (LMIC.txrxFlags & TXRX_ACK) {
Serial.println(F("Received ack"));
Serial.println(F("! Received ACK"));
_ttn_callback(EV_ACK);
}
if (LMIC.dataLen) {

Wyświetl plik

@ -21,11 +21,13 @@ build_flags = -Wall
-Wextra
-Wno-missing-field-initializers -O3 -Wl,-Map,.pio/build/esp32/output.map
-D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS
-D CFG_eu868=1
-D CFG_us915=1
-D CFG_sx1276_radio=1
; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
monitor_speed = 115200
monitor_port = COM16
upload_port = COM16
lib_deps =
mcci-catena/MCCI LoRaWAN LMIC library @ ^4.0.0