diff --git a/ap_fw/main.c b/ap_fw/main.c index 2a950f94..ceb3f6fe 100644 --- a/ap_fw/main.c +++ b/ap_fw/main.c @@ -72,6 +72,7 @@ struct AvailDataInfo { uint64_t dataVer; uint32_t dataSize; uint8_t dataType; + uint16_t nextCheckIn; } __packed; struct blockPart { @@ -89,7 +90,7 @@ struct blockData { struct pendingData { struct AvailDataInfo availdatainfo; - uint8_t attemptsLeft; + uint16_t attemptsLeft; uint8_t targetMac[8]; } __packed; @@ -98,7 +99,7 @@ struct pendingData { #define BLOCK_DATA_SIZE 4096 #define BLOCK_XFER_BUFFER_SIZE BLOCK_DATA_SIZE + sizeof(struct blockData) #define BLOCK_REQ_PARTS_BYTES 6 // BLOCK_MAX_PARTS / 8 + 1 -#define MAX_PENDING_MACS 10 +#define MAX_PENDING_MACS 64 #define HOUSEKEEPING_INTERVAL 60UL struct pendingData __xdata pendingDataArr[MAX_PENDING_MACS]; @@ -116,10 +117,6 @@ struct blockRequestAck { uint16_t pleaseWaitMs; } __packed; -struct espPendingData { - uint8_t checksum; - struct pendingData pending; -} __packed; struct espBlockRequest { uint8_t checksum; @@ -684,6 +681,7 @@ void main(void) { pendingDataArr[c].attemptsLeft = 0; } else if (pendingDataArr[c].attemptsLeft > 1) { pendingDataArr[c].attemptsLeft--; + if(pendingDataArr[c].availdatainfo.nextCheckIn)pendingDataArr[c].availdatainfo.nextCheckIn--; } } housekeepingTimer = timerGet(); diff --git a/ap_fw/zigbeebase0006.bin b/ap_fw/zigbeebase0006.bin index 7bb5bc7a..6bd4d85f 100644 Binary files a/ap_fw/zigbeebase0006.bin and b/ap_fw/zigbeebase0006.bin differ diff --git a/tag_fw/buildfw.sh b/tag_fw/buildfw.sh new file mode 100644 index 00000000..8dd3ff2a --- /dev/null +++ b/tag_fw/buildfw.sh @@ -0,0 +1,11 @@ +#!/bin/bash +make clean +make BUILD=zbs154v033 CPU=8051 SOC=zbs243 +mv main.bin fw154.bin +make clean +make BUILD=zbs29v033 CPU=8051 SOC=zbs243 +mv main.bin fw29.bin +make clean +make BUILD=zbs42v033 CPU=8051 SOC=zbs243 +mv main.bin fw42.bin + diff --git a/tag_fw/fw154.bin b/tag_fw/fw154.bin index 5926bf48..c47f7940 100644 Binary files a/tag_fw/fw154.bin and b/tag_fw/fw154.bin differ diff --git a/tag_fw/fw29.bin b/tag_fw/fw29.bin index 8c312a6a..198ee2db 100644 Binary files a/tag_fw/fw29.bin and b/tag_fw/fw29.bin differ diff --git a/tag_fw/fw42.bin b/tag_fw/fw42.bin index f8571ed9..e53388a0 100644 Binary files a/tag_fw/fw42.bin and b/tag_fw/fw42.bin differ diff --git a/tag_fw/syncedproto.c b/tag_fw/syncedproto.c index 42e28648..1f769b93 100644 --- a/tag_fw/syncedproto.c +++ b/tag_fw/syncedproto.c @@ -49,7 +49,6 @@ struct MacFrameBcast { uint8_t src[8]; } __packed; - #define PKT_AVAIL_DATA_REQ 0xE5 #define PKT_AVAIL_DATA_INFO 0xE6 #define PKT_BLOCK_PARTIAL_REQUEST 0xE7 @@ -81,6 +80,7 @@ struct AvailDataInfo { uint64_t dataVer; uint32_t dataSize; uint8_t dataType; + uint16_t nextCheckIn; } __packed; struct blockPart { @@ -155,6 +155,7 @@ uint8_t __xdata seq = 0; uint16_t __xdata dataReqAttemptArr[POWER_SAVING_SMOOTHING] = {0}; // Holds the amount of attempts required per data_req/check-in uint8_t __xdata dataReqAttemptArrayIndex = 0; uint8_t __xdata dataReqLastAttempt = 0; +uint16_t __xdata nextCheckInFromAP = 0; // buffer we use to prepare/read packets // static uint8_t __xdata mRxBuf[130]; @@ -445,7 +446,7 @@ void sendXferCompletePacket() { void sendXferComplete() { radioRxEnable(true, true); - for (uint8_t c = 0; c < 4; c++) { + for (uint8_t c = 0; c < 8; c++) { sendXferCompletePacket(); uint32_t __xdata start = timerGet(); while ((timerGet() - start) < (TIMER_TICKS_PER_MS * 6UL)) { @@ -750,7 +751,7 @@ void doDataDownload(struct AvailDataInfo *__xdata avail) { if (blockComplete) { if (validateBlockData()) { // checked and found okay - requestPartialBlock = false; // next block is going to be requested from the ESP32 by the AP + requestPartialBlock = false; // next block is going to be requested from the ESP32 by the AP blockValidateAttempt = 0; switch (curBlock.type) { case DATATYPE_IMG: @@ -891,12 +892,21 @@ void mainProtocolLoop(void) { radioRxEnable(true, true); struct AvailDataInfo *__xdata avail = getAvailDataInfo(); if (avail == NULL) { + nextCheckInFromAP = 0; } else { + nextCheckInFromAP = avail->nextCheckIn; if (avail->dataType != DATATYPE_NOUPDATE) { doDataDownload(avail); } else { + // just sleep } } - doSleep(getNextSleep() * 1000UL); + + // if the AP told us to sleep for a specific period, do so. + if (nextCheckInFromAP) { + doSleep(nextCheckInFromAP * 60000UL); + } else { + doSleep(getNextSleep() * 1000UL); + } } } \ No newline at end of file