diff --git a/ap_fw/main.c b/ap_fw/main.c index 573816c5..d5149570 100644 --- a/ap_fw/main.c +++ b/ap_fw/main.c @@ -60,6 +60,7 @@ struct AvailDataReq { uint8_t softVer; uint8_t hwType; uint8_t protoVer; + //uint8_t buttonState; } __packed; #define DATATYPE_NOUPDATE 0 diff --git a/esp32_fw/include/commstructs.h b/esp32_fw/include/commstructs.h index b9b6a5d6..8afb0a75 100644 --- a/esp32_fw/include/commstructs.h +++ b/esp32_fw/include/commstructs.h @@ -27,6 +27,7 @@ struct AvailDataReq { uint8_t softVer; uint8_t hwType; uint8_t protoVer; + //uint8_t buttonState; } __packed; struct espAvailDataReq { diff --git a/esp32_fw/src/newproto.cpp b/esp32_fw/src/newproto.cpp index 44900621..00f130f0 100644 --- a/esp32_fw/src/newproto.cpp +++ b/esp32_fw/src/newproto.cpp @@ -147,7 +147,7 @@ void processDataReq(struct espAvailDataReq* eadr) { uint8_t src[8]; // *((uint64_t*)src) = swap64(*((uint64_t*)adr->)); sprintf(buffer, "src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0]); - // sprintf(buffer, "softVer, adr->batteryMv); + sprintf(buffer, "adr->protoVer); wsString((String)buffer); Serial.print(buffer); } diff --git a/tag_fw/fw29.bin b/tag_fw/fw29.bin index d90d2501..60dda2ec 100644 Binary files a/tag_fw/fw29.bin and b/tag_fw/fw29.bin differ diff --git a/tag_fw/syncedproto.c b/tag_fw/syncedproto.c index 10a43b93..0e571f88 100644 --- a/tag_fw/syncedproto.c +++ b/tag_fw/syncedproto.c @@ -68,6 +68,7 @@ struct AvailDataReq { uint8_t softVer; uint8_t hwType; uint8_t protoVer; + //uint8_t buttonState; } __packed; #define DATATYPE_NOUPDATE 0 @@ -252,8 +253,36 @@ void initAfterWake() { void doSleep(uint32_t __xdata t) { if(t>1000)pr("s=%lu\n ", t / 1000); powerPortsDownForSleep(); + + //Button setup on TEST pin 1.0 (input pullup) + uint8_t tmp_P1FUNC = P1FUNC; + uint8_t tmp_P1DIR = P1DIR; + uint8_t tmp_P1PULL = P1PULL; + uint8_t tmp_P1LVLSEL = P1LVLSEL; + + P1FUNC &=~ (1 << 0); + P1DIR |= (1 << 0); + P1PULL |= (1 << 0); + + P1LVLSEL |= (1 << 0); + P1CHSTA &=~ (1 << 0); + P0INTEN = 0; + P1INTEN = (1 << 0); + P2INTEN = 0; + P1CHSTA &=~ (1 << 0); + // sleepy sleepForMsec(t); + + P0INTEN = 0; + P1INTEN = 0; + P2INTEN = 0; + + P1FUNC = tmp_P1FUNC; + P1DIR = tmp_P1DIR; + P1PULL = tmp_P1PULL; + P1LVLSEL = tmp_P1LVLSEL; + initAfterWake(); } uint16_t getNextSleep() { @@ -295,6 +324,11 @@ void sendAvailDataReq() { txframe->srcPan = 0x4447; // TODO: send some meaningful data availreq->softVer = 1; + if (P1CHSTA && (1 << 0)) { + availreq->protoVer = 1; //buttonState + pr("button pressed\n"); + P1CHSTA &=~ (1 << 0); + } addCRC(availreq, sizeof(struct AvailDataReq)); commsTxNoCpy(outBuffer); } @@ -897,6 +931,9 @@ void mainProtocolLoop(void) { screenSleep(); eepromDeepPowerDown(); initRadio(); + + P1CHSTA &=~ (1 << 0); + // drawPartial(); // i2ctest(); // doSleep(10000);