mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 10:06:07 +01:00
TTL support! (Nic's idea)
This commit is contained in:
10
ap_fw/main.c
10
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();
|
||||
|
||||
Binary file not shown.
11
tag_fw/buildfw.sh
Normal file
11
tag_fw/buildfw.sh
Normal 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
|
||||
|
||||
BIN
tag_fw/fw154.bin
BIN
tag_fw/fw154.bin
Binary file not shown.
BIN
tag_fw/fw29.bin
BIN
tag_fw/fw29.bin
Binary file not shown.
BIN
tag_fw/fw42.bin
BIN
tag_fw/fw42.bin
Binary file not shown.
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user