reverted back to old AP strategy

This commit is contained in:
jjwbruijn
2023-03-28 22:15:38 +02:00
parent bf66a49038
commit 984f46c4f1
10 changed files with 39 additions and 14 deletions

Binary file not shown.

Binary file not shown.

0
binaries/Tag_FW_1.54.bin Normal file → Executable file
View File

0
binaries/Tag_FW_2.9-uc8151.bin Normal file → Executable file
View File

0
binaries/Tag_FW_2.9.bin Normal file → Executable file
View File

0
binaries/Tag_FW_4.2.bin Normal file → Executable file
View File

Binary file not shown.

BIN
binaries/zigbeebase000F.bin Normal file

Binary file not shown.

26
zbs243_AP_FW/main.c Normal file → Executable file
View File

@@ -38,7 +38,7 @@ struct espAvailDataReq {
struct AvailDataReq adr;
} __packed;
//#define TIMER_TICKS_PER_MS 1333UL
// #define TIMER_TICKS_PER_MS 1333UL
uint16_t __xdata version = 0x000E;
#define RAW_PKT_PADDING 2
@@ -63,10 +63,11 @@ struct blockRequest __xdata requestedData = {0}; // holds which data was reques
uint8_t __xdata dstMac[8]; // target for the block transfer
uint16_t __xdata dstPan; //
static uint32_t __xdata blockStartTimer = 0; // reference that holds when the AP sends the next block
uint32_t __xdata nextBlockAttempt = 0; // reference time for when the AP can request a new block from the ESP32
uint8_t seq = 0; // holds current sequence number for transmission
uint8_t __xdata blockbuffer[BLOCK_XFER_BUFFER_SIZE+5]; // block transfer buffer
static uint32_t __xdata blockStartTimer = 0; // reference that holds when the AP sends the next block
extern bool __idata serialBypassActive; // if the serial bypass is disabled, saves bytes straight to the block buffer
uint32_t __xdata nextBlockAttempt = 0; // reference time for when the AP can request a new block from the ESP32
uint8_t seq = 0; // holds current sequence number for transmission
uint8_t __xdata blockbuffer[BLOCK_XFER_BUFFER_SIZE + 5]; // block transfer buffer
uint8_t lastAckMac[8] = {0};
// these variables hold the current mac were talking to
@@ -194,6 +195,13 @@ void processSerial(uint8_t lastchar) {
cmdbuffer[c] = cmdbuffer[c + 1];
}
cmdbuffer[3] = lastchar;
if (strncmp(cmdbuffer + 1, ">D>", 3) == 0) {
blockp = blockbuffer;
pr("ACK>\n");
serialBypassActive = true;
}
if (strncmp(cmdbuffer, "SDA>", 4) == 0) {
RXState = ZBS_RX_WAIT_SDA;
bytesRemain = sizeof(struct pendingData);
@@ -206,11 +214,6 @@ void processSerial(uint8_t lastchar) {
serialbufferp = serialbuffer;
break;
}
if (strncmp(cmdbuffer+1, ">D>", 3) == 0) {
blockp = blockbuffer;
pr("ACK>\n");
}
if (strncmp(cmdbuffer, "VER?", 4) == 0) {
pr("VER>%04X\n", version);
}
@@ -410,6 +413,7 @@ void processBlockRequest(const uint8_t *buffer, uint8_t forceBlockDownload) {
dstPan = rxHeader->pan;
if (requestDataDownload) {
serialBypassActive = false;
espBlockRequest(&requestedData);
nextBlockAttempt = timerGet();
}
@@ -652,7 +656,7 @@ void main(void) {
}
loopCount--;
if (loopCount == 0) {
wdt10s();
wdt60s();
loopCount = 10000;
// every once in a while, especially when handling a lot of traffic, the radio will hang. Calling this every once in while
// alleviates this problem. The radio is set back to 'receive' whenever loopCount overflows

27
zbs243_shared/soc/zbs243/uart.c Normal file → Executable file
View File

@@ -12,7 +12,8 @@ void uartInit(void) {
// configure baud rate
UARTBRGH = 0x00;
#ifdef AP_FW
UARTBRGL = 69; // nice. 230400 baud
//UARTBRGL = 69; // nice. 230400 baud
UARTBRGL = 70; // 79 == 200k
IEN_UART0 = 1;
#else
UARTBRGL = 0x8A; // config for 115200
@@ -29,6 +30,8 @@ void uartTx(uint8_t val) {
}
#else
extern uint8_t __xdata blockbuffer[];
volatile uint8_t txtail = 0;
volatile uint8_t txhead = 0;
uint8_t __xdata txbuf[256] = {0};
@@ -62,15 +65,33 @@ uint8_t uartBytesAvail() {
}
uint8_t* __idata blockp;
uint8_t __idata cmd[3];
volatile bool __idata serialBypassActive = false;
void checkcommand(uint8_t rx) {
for (uint8_t c = 0; c < 2; c++) {
cmd[c] = cmd[c + 1];
}
cmd[2] = rx;
if (strncmp(cmd, ">D>", 3) == 0) {
blockp = blockbuffer;
serialBypassActive = true;
}
}
void UART_IRQ1(void) __interrupt(0) {
if (UARTSTA & 1) { // RXC
UARTSTA &= 0xfe;
if (P0_2) {
if (serialBypassActive) {
*blockp++ = UARTBUF;
if (blockp == (blockbuffer + 4100)) {
serialBypassActive = false;
blockp = blockbuffer;
}
} else {
rxbuf[rxhead] = UARTBUF;
rxhead++;
//checkcommand(UARTBUF);
}
}
if (UARTSTA & 2) { // TXC
@@ -81,4 +102,4 @@ void UART_IRQ1(void) __interrupt(0) {
}
}
}
#endif
#endif