Merge pull request #772 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot 2021-03-27 19:03:31 +01:00 committed by GitHub
commit e015d399c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 522 additions and 510 deletions

View File

@ -530,8 +530,8 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat
0x19 set sleep cycle 0x19 set sleep cycle
0 ... 255 device sleep cycle in seconds/2 bytes 1..2 = device sleep cycle in seconds/10 (MSB)
e.g. 120 -> device sleeps 240 seconds after each send cycle [default = 0] e.g. {0x04, 0xB0} -> device sleeps 20 minutes after each send cycle [default = 0]
0x20 load device configuration 0x20 load device configuration
@ -579,10 +579,13 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat
0x01 = timeNeedsSync (last sync failed) 0x01 = timeNeedsSync (last sync failed)
0x02 = timeSet (synched) 0x02 = timeSet (synched)
0x87 set time/date 0x87 sync time/date
Device synchronizes it's time/date by calling the preconfigured time source. Device synchronizes it's time/date by calling the preconfigured time source.
0x88 set time/date
bytes 1..4 = time/date to set in UTC epoch seconds (MSB, e.g. https://www.epochconverter.com/hex)
# License # License

View File

@ -74,7 +74,7 @@ typedef struct __attribute__((packed)) {
uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed
int16_t rssilimit; // threshold for rssilimiter, negative value! int16_t rssilimit; // threshold for rssilimiter, negative value!
uint8_t sendcycle; // payload send cycle [seconds/2] uint8_t sendcycle; // payload send cycle [seconds/2]
uint8_t sleepcycle; // sleep cycle [seconds/2] uint16_t sleepcycle; // sleep cycle [seconds/10]
uint8_t wifichancycle; // wifi channel switch cycle [seconds/100] uint8_t wifichancycle; // wifi channel switch cycle [seconds/100]
uint8_t blescantime; // BLE scan cycle duration [seconds] uint8_t blescantime; // BLE scan cycle duration [seconds]
uint8_t blescan; // 0=disabled, 1=enabled uint8_t blescan; // 0=disabled, 1=enabled

View File

@ -25,7 +25,7 @@
"t": "set", "t": "set",
"p": "payload.schedule", "p": "payload.schedule",
"pt": "msg", "pt": "msg",
"to": "replace", "to": "first",
"tot": "str" "tot": "str"
}, },
{ {

View File

@ -42,7 +42,7 @@ static void defaultConfig(configData_t *myconfig) {
COUNTERMODE; // 0=cyclic, 1=cumulative, 2=cyclic confirmed COUNTERMODE; // 0=cyclic, 1=cumulative, 2=cyclic confirmed
myconfig->rssilimit = 0; // threshold for rssilimiter, negative value! myconfig->rssilimit = 0; // threshold for rssilimiter, negative value!
myconfig->sendcycle = SENDCYCLE; // payload send cycle [seconds/2] myconfig->sendcycle = SENDCYCLE; // payload send cycle [seconds/2]
myconfig->sleepcycle = SLEEPCYCLE; // sleep cycle [seconds/2] myconfig->sleepcycle = SLEEPCYCLE; // sleep cycle [seconds/10]
myconfig->wifichancycle = myconfig->wifichancycle =
WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100] WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
myconfig->blescantime = myconfig->blescantime =

View File

@ -90,9 +90,9 @@ void irqHandler(void *pvParameters) {
// goto sleep if we have a sleep cycle // goto sleep if we have a sleep cycle
if (cfg.sleepcycle) if (cfg.sleepcycle)
#ifdef HAS_BUTTON #ifdef HAS_BUTTON
enter_deepsleep(cfg.sleepcycle * 2, (gpio_num_t)HAS_BUTTON); enter_deepsleep(cfg.sleepcycle * 10, (gpio_num_t)HAS_BUTTON);
#else #else
enter_deepsleep(cfg.sleepcycle * 2); enter_deepsleep(cfg.sleepcycle * 10);
#endif #endif
} }
} // for } // for

View File

@ -14,13 +14,13 @@
// Payload send cycle and encoding // Payload send cycle and encoding
#define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255 #define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255
#define SLEEPCYCLE 0 // sleep time after a send cycle [seconds/2], 0 .. 255; 0 means no sleep [default = 0] #define SLEEPCYCLE 0 // sleep time after a send cycle [seconds/10], 0 .. 65535; 0 means no sleep [default = 0]
#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed #define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed
#define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed #define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed
// MAC sniffing parameters // MAC sniffing parameters
#define MACFILTER 1 // set to 0 if you want to scan all devices, 1 to scan only devices with random MACs (aka smartphones) [default = 1] #define MACFILTER 1 // set to 0 if you want to scan all devices, 1 to scan only devices with random MACs (aka smartphones) [default = 1]
#define BLECOUNTER 0 // set to 0 if you do not want to install the BLE sniffer #define BLECOUNTER 1 // set to 0 if you do not want to install the BLE sniffer
#define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer #define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer
#define MAC_QUEUE_SIZE 50 // size of MAC processing buffer (number of MACs) [default = 50] #define MAC_QUEUE_SIZE 50 // size of MAC processing buffer (number of MACs) [default = 50]

View File

@ -68,9 +68,11 @@ void set_sendcycle(uint8_t val[]) {
} }
void set_sleepcycle(uint8_t val[]) { void set_sleepcycle(uint8_t val[]) {
cfg.sleepcycle = val[0]; // swap byte order from msb to lsb, note: this is a platform dependent hack
uint16_t t = __builtin_bswap16(*(uint16_t *)(val));
cfg.sleepcycle = t;
ESP_LOGI(TAG, "Remote command: set sleep cycle to %d seconds", ESP_LOGI(TAG, "Remote command: set sleep cycle to %d seconds",
cfg.sleepcycle * 2); cfg.sleepcycle * 10);
} }
void set_wifichancycle(uint8_t val[]) { void set_wifichancycle(uint8_t val[]) {
@ -346,11 +348,18 @@ void get_time(uint8_t val[]) {
SendPayload(TIMEPORT); SendPayload(TIMEPORT);
}; };
void set_time(uint8_t val[]) { void set_timesync(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: timesync requested"); ESP_LOGI(TAG, "Remote command: timesync requested");
setTimeSyncIRQ(); setTimeSyncIRQ();
}; };
void set_time(uint8_t val[]) {
// swap byte order from msb to lsb, note: this is a platform dependent hack
uint32_t t = __builtin_bswap32(*(uint32_t *)(val));
ESP_LOGI(TAG, "Remote command: set time to %d", t);
setMyTime(t, 0, _unsynced);
};
void set_flush(uint8_t val[]) { void set_flush(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: flush"); ESP_LOGI(TAG, "Remote command: flush");
// does nothing // does nothing
@ -392,12 +401,12 @@ static const cmd_t table[] = {
{0x13, set_sensor, 2}, {0x14, set_payloadmask, 1}, {0x13, set_sensor, 2}, {0x14, set_payloadmask, 1},
{0x15, set_bme, 1}, {0x16, set_batt, 1}, {0x15, set_bme, 1}, {0x16, set_batt, 1},
{0x17, set_wifiscan, 1}, {0x18, set_enscount, 1}, {0x17, set_wifiscan, 1}, {0x18, set_enscount, 1},
{0x19, set_sleepcycle, 1}, {0x20, set_loadconfig, 0}, {0x19, set_sleepcycle, 2}, {0x20, set_loadconfig, 0},
{0x21, set_saveconfig, 0}, {0x80, get_config, 0}, {0x21, set_saveconfig, 0}, {0x80, get_config, 0},
{0x81, get_status, 0}, {0x83, get_batt, 0}, {0x81, get_status, 0}, {0x83, get_batt, 0},
{0x84, get_gps, 0}, {0x85, get_bme, 0}, {0x84, get_gps, 0}, {0x85, get_bme, 0},
{0x86, get_time, 0}, {0x87, set_time, 0}, {0x86, get_time, 0}, {0x87, set_timesync, 0},
{0x99, set_flush, 0}}; {0x88, set_time, 4}, {0x99, set_flush, 0}};
static const uint8_t cmdtablesize = static const uint8_t cmdtablesize =
sizeof(table) / sizeof(table[0]); // number of commands in command table sizeof(table) / sizeof(table[0]); // number of commands in command table