From 537977a2dba2d1370e5205148dbe8ab2e89130bd Mon Sep 17 00:00:00 2001 From: Jelmer Date: Thu, 2 Feb 2023 16:31:29 +0100 Subject: [PATCH] improved structs for esp32 fw --- esp32_fw/include/commstructs.h | 35 +++++++++++++++++++++------------- esp32_fw/include/settings.h | 21 +++++++++++++------- esp32_fw/platformio.ini | 4 ++-- esp32_fw/src/newproto.cpp | 2 +- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/esp32_fw/include/commstructs.h b/esp32_fw/include/commstructs.h index ac93dba7..af410302 100644 --- a/esp32_fw/include/commstructs.h +++ b/esp32_fw/include/commstructs.h @@ -18,17 +18,25 @@ struct blockData { uint8_t data[]; } __packed; +#define SOLUM_154_033 0 +#define SOLUM_29_033 1 +#define SOLUM_42_033 2 + +#define WAKEUP_REASON_TIMED 0 +#define WAKEUP_REASON_BOOTUP 1 +#define WAKEUP_REASON_GPIO 2 +#define WAKEUP_REASON_NFC 3 + struct AvailDataReq { uint8_t checksum; - uint8_t lastPacketLQI; // zero if not reported/not supported to be reported - int8_t lastPacketRSSI; // zero if not reported/not supported to be reported - uint8_t temperature; // zero if not reported/not supported to be reported. else, this minus CHECKIN_TEMP_OFFSET is temp in degrees C - uint16_t batteryMv; - uint8_t softVer; - uint8_t hwType; - uint8_t protoVer; - uint8_t buttonState; -} __packed; + uint8_t lastPacketLQI : 7; + uint8_t lastPacketRSSI : 7; // is negative + int8_t temperature : 7; // zero if not reported/not supported to be reported. else, this minus CHECKIN_TEMP_OFFSET is temp in degrees C + uint16_t batteryMv : 12; + uint8_t hwType : 5; // 32 types of tags supported + uint8_t wakeupReason : 2; // supports 4 types of wakeup reasons + uint8_t capabilities; // undefined, as of now +} __packed; // 7 bytes struct espAvailDataReq { uint8_t checksum; @@ -43,10 +51,11 @@ struct espAvailDataReq { struct AvailDataInfo { uint8_t checksum; - uint64_t dataVer; - uint32_t dataSize; - uint8_t dataType; - uint16_t nextCheckIn; + uint64_t dataVer; // MD5 of potential traffic + uint32_t dataSize; + uint8_t dataType : 4; // allows for 16 different datatypes + uint8_t dataTypeArgument : 4; // extra specification or instruction for the tag (LUT to be used for drawing image) + uint16_t nextCheckIn; // when should the tag check-in again? Measured in minutes } __packed; struct pendingData { diff --git a/esp32_fw/include/settings.h b/esp32_fw/include/settings.h index 279d774a..117bb857 100644 --- a/esp32_fw/include/settings.h +++ b/esp32_fw/include/settings.h @@ -28,15 +28,22 @@ // flasher options #define CUSTOM_MAC_HDR 0x0000 -#define RXD1 16 -#define TXD1 17 +//#define RXD1 16 +//#define TXD1 17 -#define ZBS_SS 5 +// connections to the tag +//#define RXD1 16 //was 16 - 13 +//#define TXD1 17 // was 17 - 12 + +#define RXD1 13 // 1st +#define TXD1 12 // 2nd + +#define ZBS_SS 21 #define ZBS_CLK 18 -#define ZBS_MoSi 23 +#define ZBS_MoSi 22 #define ZBS_MiSo 19 -#define ZBS_Reset 2 -#define ZBS_POWER1 13 -#define ZBS_POWER2 15 +#define ZBS_Reset 5 +#define ZBS_POWER1 15 +#define ZBS_POWER2 2 #define MAX_WRITE_ATTEMPTS 5 diff --git a/esp32_fw/platformio.ini b/esp32_fw/platformio.ini index 99d85fe2..77108edd 100644 --- a/esp32_fw/platformio.ini +++ b/esp32_fw/platformio.ini @@ -24,5 +24,5 @@ lib_deps = bblanchon/ArduinoJson bodmer/TFT_eSPI https://github.com/Bodmer/TJpg_Decoder.git -upload_port = COM5 -monitor_port = COM5 +upload_port = COM12 +monitor_port = COM12 diff --git a/esp32_fw/src/newproto.cpp b/esp32_fw/src/newproto.cpp index 76fbfd40..fae837dd 100644 --- a/esp32_fw/src/newproto.cpp +++ b/esp32_fw/src/newproto.cpp @@ -271,7 +271,7 @@ void processDataReq(struct espAvailDataReq* eadr) { time(&now); taginfo->lastseen = now; taginfo->expectedNextCheckin = now + 300; - taginfo->button = (eadr->adr.buttonState == 1); + taginfo->button = (eadr->adr.wakeupReason==WAKEUP_REASON_GPIO); sprintf(buffer, "