TTL support! (Nic's idea)

This commit is contained in:
Jelmer
2023-01-22 01:45:54 +01:00
parent a666994346
commit 050b345fb1
7 changed files with 29 additions and 10 deletions

View File

@@ -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();

Binary file not shown.

11
tag_fw/buildfw.sh Normal file
View File

@@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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);
}
}
}