diff --git a/binaries/AP_FW-dma.bin b/binaries/AP_FW-dma.bin deleted file mode 100644 index cdf49b09..00000000 Binary files a/binaries/AP_FW-dma.bin and /dev/null differ diff --git a/binaries/AP_FW-universal.bin b/binaries/AP_FW-universal.bin index 426cf800..b196e69a 100644 Binary files a/binaries/AP_FW-universal.bin and b/binaries/AP_FW-universal.bin differ diff --git a/binaries/Tag_FW_1.54.bin b/binaries/Tag_FW_1.54.bin old mode 100644 new mode 100755 diff --git a/binaries/Tag_FW_2.9-uc8151.bin b/binaries/Tag_FW_2.9-uc8151.bin old mode 100644 new mode 100755 diff --git a/binaries/Tag_FW_2.9.bin b/binaries/Tag_FW_2.9.bin old mode 100644 new mode 100755 diff --git a/binaries/Tag_FW_4.2.bin b/binaries/Tag_FW_4.2.bin old mode 100644 new mode 100755 diff --git a/binaries/zigbeebase000E.bin b/binaries/zigbeebase000E.bin deleted file mode 100644 index cdf49b09..00000000 Binary files a/binaries/zigbeebase000E.bin and /dev/null differ diff --git a/binaries/zigbeebase000F.bin b/binaries/zigbeebase000F.bin new file mode 100644 index 00000000..b196e69a Binary files /dev/null and b/binaries/zigbeebase000F.bin differ diff --git a/zbs243_AP_FW/main.c b/zbs243_AP_FW/main.c old mode 100644 new mode 100755 index fd693d2c..ba5dd9b5 --- a/zbs243_AP_FW/main.c +++ b/zbs243_AP_FW/main.c @@ -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 diff --git a/zbs243_shared/soc/zbs243/uart.c b/zbs243_shared/soc/zbs243/uart.c old mode 100644 new mode 100755 index d3b51034..95ad84ee --- a/zbs243_shared/soc/zbs243/uart.c +++ b/zbs243_shared/soc/zbs243/uart.c @@ -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 \ No newline at end of file +#endif