diff --git a/binaries/AP_FW_1.54.bin b/binaries/AP_FW_1.54.bin index e7d55833..1de05ef5 100644 Binary files a/binaries/AP_FW_1.54.bin and b/binaries/AP_FW_1.54.bin differ diff --git a/binaries/AP_FW_2.9.bin b/binaries/AP_FW_2.9.bin index 4174e0df..4f7dd184 100644 Binary files a/binaries/AP_FW_2.9.bin and b/binaries/AP_FW_2.9.bin differ diff --git a/binaries/AP_FW_Nodisplay.bin b/binaries/AP_FW_Nodisplay.bin index 891d6ed2..44359bb9 100644 Binary files a/binaries/AP_FW_Nodisplay.bin and b/binaries/AP_FW_Nodisplay.bin differ diff --git a/binaries/AP_FW_Pack.bin b/binaries/AP_FW_Pack.bin index d9bf54db..f221973b 100644 Binary files a/binaries/AP_FW_Pack.bin and b/binaries/AP_FW_Pack.bin differ diff --git a/binaries/AP_FW_Segmented_UK.bin b/binaries/AP_FW_Segmented_UK.bin index 4f3c2ed8..ae3ce93a 100644 Binary files a/binaries/AP_FW_Segmented_UK.bin and b/binaries/AP_FW_Segmented_UK.bin differ diff --git a/binaries/Tag_FW_1.54.bin b/binaries/Tag_FW_1.54.bin index 64319dc2..7fb4eccc 100644 Binary files a/binaries/Tag_FW_1.54.bin and b/binaries/Tag_FW_1.54.bin differ diff --git a/binaries/Tag_FW_2.9-uc8151.bin b/binaries/Tag_FW_2.9-uc8151.bin index f79a7d31..eaa053d3 100644 Binary files a/binaries/Tag_FW_2.9-uc8151.bin and b/binaries/Tag_FW_2.9-uc8151.bin differ diff --git a/binaries/Tag_FW_2.9.bin b/binaries/Tag_FW_2.9.bin index ce312351..ec14fef9 100644 Binary files a/binaries/Tag_FW_2.9.bin and b/binaries/Tag_FW_2.9.bin differ diff --git a/binaries/Tag_FW_4.2.bin b/binaries/Tag_FW_4.2.bin index c6b765fa..e08cbebe 100644 Binary files a/binaries/Tag_FW_4.2.bin and b/binaries/Tag_FW_4.2.bin differ diff --git a/binaries/Tag_FW_Pack.bin b/binaries/Tag_FW_Pack.bin index da9eef93..c7633ddd 100644 Binary files a/binaries/Tag_FW_Pack.bin and b/binaries/Tag_FW_Pack.bin differ diff --git a/zbs243_AP_FW/APDisplay.c b/zbs243_AP_FW/APDisplay.c index 0f5cf282..d07ac1e4 100755 --- a/zbs243_AP_FW/APDisplay.c +++ b/zbs243_AP_FW/APDisplay.c @@ -12,7 +12,8 @@ #include "comms.h" #include "cpu.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" #include "radio.h" #include "screen.h" #include "timer.h" @@ -104,4 +105,4 @@ void epdShowRun() { #endif -#endif \ No newline at end of file +#endif diff --git a/zbs243_AP_FW/comms.c b/zbs243_AP_FW/comms.c index 36126866..fa53d92e 100644 --- a/zbs243_AP_FW/comms.c +++ b/zbs243_AP_FW/comms.c @@ -3,7 +3,7 @@ #include #include "asmUtil.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" #include "radio.h" static uint8_t __xdata mCommsBuf[127]; @@ -46,4 +46,4 @@ bool commsTxUnencrypted(const void __xdata *packetP, uint8_t len) { bool commsTxNoCpy(const void __xdata *packetp) { return radioTx(packetp); -} \ No newline at end of file +} diff --git a/zbs243_AP_FW/emulateTag.c b/zbs243_AP_FW/emulateTag.c index c0807b7e..1443803b 100755 --- a/zbs243_AP_FW/emulateTag.c +++ b/zbs243_AP_FW/emulateTag.c @@ -7,12 +7,12 @@ #include #include #include - #include "asmUtil.h" #include "comms.h" #include "cpu.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" #include "radio.h" #include "screen.h" #include "timer.h" @@ -174,4 +174,4 @@ void fakeTagCheckIn() { espNotifyAvailDataReq(adr, fakeTagMac); } -#endif \ No newline at end of file +#endif diff --git a/zbs243_AP_FW/main.c b/zbs243_AP_FW/main.c index 1a28048e..8bf4745c 100755 --- a/zbs243_AP_FW/main.c +++ b/zbs243_AP_FW/main.c @@ -5,12 +5,15 @@ #include #include +#include "../oepl-definitions.h" +#include "../oepl-proto.h" +#include "../oepl-esp-ap-proto.h" + #include "asmUtil.h" #include "board.h" #include "comms.h" #include "cpu.h" #include "printf.h" -#include "proto.h" #include "radio.h" #include "timer.h" #include "uart.h" @@ -30,7 +33,7 @@ struct pendingData __xdata pendingDataArr[MAX_PENDING_MACS]; // VERSION GOES HERE! -uint16_t __xdata version = 0x0017; +uint16_t __xdata version = 0x0019; #define RAW_PKT_PADDING 2 @@ -61,6 +64,7 @@ uint8_t *__xdata blockXferBuffer = blockbuffer; #define CONCURRENT_REQUEST_DELAY 1200UL * TIMER_TICKS_PER_MS uint32_t __xdata lastBlockRequest = 0; uint8_t __xdata lastBlockMac[8]; +uint8_t __xdata lastTagReturn[8]; uint8_t __xdata curChannel = 11; uint8_t __xdata curPower = 10; @@ -416,9 +420,32 @@ void espNotifyAPInfo() { countSlots(); pr("PEN>%02X\n", curPendingData); pr("NOP>%02X\n", curNoUpdate); -//#if (AP_EMULATE_TAG == 1) -// fakeTagCheckIn(); // removed this for now to ensure IP info is properly displayed; first tag check in now happens after the first round of housekeeping (30s) -//#endif + // #if (AP_EMULATE_TAG == 1) + // fakeTagCheckIn(); // removed this for now to ensure IP info is properly displayed; first tag check in now happens after the first round of housekeeping (30s) + // #endif +} +void espNotifyTagReturnData(uint8_t *src, uint8_t len) { + struct tagReturnData *trd = (struct tagReturnData *)(radiorxbuffer + sizeof(struct MacFrameBcast) + 1); // oh how I'd love to pass this as an argument, but sdcc won't let me + struct espTagReturnData *etrd = (struct espTagReturnData *)radiotxbuffer; + + if (memcmp((void *__xdata) & trd->dataVer, lastTagReturn, 8) == 0) { + return; + } else { + xMemCopyShort((void *__xdata)lastTagReturn, (void *__xdata) & trd->dataVer, 8); + } + + memcpy(etrd->src, src, 8); + etrd->len = len; + memcpy((void*)etrd->returnData, trd, len); + addCRC(etrd, len+10); + + uartTx('T'); + uartTx('R'); + uartTx('D'); + uartTx('>'); + for (uint8_t c = 0; c < len+10; c++) { + uartTx(((uint8_t *)etrd)[c]); + } } // process data from tag @@ -581,6 +608,25 @@ void processXferComplete(uint8_t *buffer) { if (slot != -1) pendingDataArr[slot].attemptsLeft = 0; } } +void processTagReturnData(uint8_t *buffer, uint8_t len) { + struct MacFrameBcast *rxframe = (struct MacFrameBcast *)buffer; + struct MacFrameNormal *frameHeader = (struct MacFrameNormal *)(radiotxbuffer + 1); + + if (!checkCRC((buffer + sizeof(struct MacFrameBcast) + 1), len - (sizeof(struct MacFrameBcast) + 1))) { + return; + } + radiotxbuffer[sizeof(struct MacFrameNormal) + 1] = PKT_TAG_RETURN_DATA_ACK; + radiotxbuffer[0] = sizeof(struct MacFrameNormal) + 1 + RAW_PKT_PADDING; + memcpy(frameHeader->src, mSelfMac, 8); + memcpy(frameHeader->dst, rxframe->src, 8); + radiotxbuffer[1] = 0x41; // fast way to set the appropriate bits + radiotxbuffer[2] = 0xCC; // normal frame + frameHeader->seq = seq++; + frameHeader->pan = rxframe->srcPan; + radioTx(radiotxbuffer); + + espNotifyTagReturnData(rxframe->src, len - (sizeof(struct MacFrameBcast) + 1)); +} // send block data to the tag void sendPart(uint8_t partNo) { @@ -769,8 +815,11 @@ void main(void) { processAvailDataReq(radiorxbuffer); } break; + case PKT_TAG_RETURN_DATA: + processTagReturnData(radiorxbuffer, ret); + break; default: - pr("t=%02X\n", getPacketType(radiorxbuffer)); + // pr("t=%02X\n", getPacketType(radiorxbuffer)); break; } loopCount = 10000; @@ -805,6 +854,7 @@ void main(void) { #if (AP_EMULATE_TAG == 1) fakeTagCheckIn(); #endif + memset(&lastTagReturn, 0, 8); for (uint8_t __xdata c = 0; c < MAX_PENDING_MACS; c++) { if (pendingDataArr[c].attemptsLeft == 1) { if (pendingDataArr[c].availdatainfo.dataType != DATATYPE_NOUPDATE) { diff --git a/zbs243_AP_FW/proto.h b/zbs243_AP_FW/proto.h deleted file mode 120000 index fed53c0e..00000000 --- a/zbs243_AP_FW/proto.h +++ /dev/null @@ -1 +0,0 @@ -../zbs243_shared/proto.h \ No newline at end of file diff --git a/zbs243_Tag_FW/comms.c b/zbs243_Tag_FW/comms.c old mode 100644 new mode 100755 index 10c6557c..f309f8bc --- a/zbs243_Tag_FW/comms.c +++ b/zbs243_Tag_FW/comms.c @@ -1,8 +1,6 @@ #define __packed #include - -#include "proto.h" #include "asmUtil.h" #include "printf.h" #include "radio.h" diff --git a/zbs243_Tag_FW/drawing.c b/zbs243_Tag_FW/drawing.c old mode 100644 new mode 100755 index 8e57f8b1..2480c21b --- a/zbs243_Tag_FW/drawing.c +++ b/zbs243_Tag_FW/drawing.c @@ -8,7 +8,7 @@ #include "eeprom.h" #include "screen.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" #include "screen.h" #include "timer.h" #include "userinterface.h" // for addIcons diff --git a/zbs243_Tag_FW/i2cdevices.c b/zbs243_Tag_FW/i2cdevices.c index 5cc02abc..3f377000 100755 --- a/zbs243_Tag_FW/i2cdevices.c +++ b/zbs243_Tag_FW/i2cdevices.c @@ -17,7 +17,10 @@ #include "i2c.h" #include "printf.h" #include "timer.h" -#include "proto.h" + +#define __packed +#include "../oepl-definitions.h" +#include "../oepl-proto.h" extern void dump(uint8_t* __xdata a, uint16_t __xdata l); // remove me when done diff --git a/zbs243_Tag_FW/main.c b/zbs243_Tag_FW/main.c index 69025416..c1a36f4c 100755 --- a/zbs243_Tag_FW/main.c +++ b/zbs243_Tag_FW/main.c @@ -12,7 +12,7 @@ #include "i2cdevices.h" #include "powermgt.h" #include "printf.h" -#include "proto.h" + #include "radio.h" #include "screen.h" #include "settings.h" @@ -21,6 +21,10 @@ #include "userinterface.h" #include "wdt.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" + + // #define DEBUG_MODE static const uint64_t __code __at(0x008b) mVersionRom = 0x1000011300000000ull; @@ -255,6 +259,15 @@ void TagAssociated() { } } else { powerUp(INIT_RADIO); + + + +#ifdef ENABLE_RETURN_DATA + // example code to send data back to the AP. Up to 90 bytes can be sent in one packet + uint8_t __xdata blaat[2] = {0xAB, 0xBA}; + sendTagReturnData(blaat, 2, 0x55); +#endif + avail = getShortAvailDataInfo(); powerDown(INIT_RADIO); } diff --git a/zbs243_Tag_FW/powermgt.c b/zbs243_Tag_FW/powermgt.c index d8d5022e..d403eac9 100755 --- a/zbs243_Tag_FW/powermgt.c +++ b/zbs243_Tag_FW/powermgt.c @@ -15,7 +15,8 @@ #include "i2c.h" #include "i2cdevices.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" #include "radio.h" #include "screen.h" #include "settings.h" diff --git a/zbs243_Tag_FW/powermgt.h b/zbs243_Tag_FW/powermgt.h index e43a07ca..f93bc3a1 100755 --- a/zbs243_Tag_FW/powermgt.h +++ b/zbs243_Tag_FW/powermgt.h @@ -30,6 +30,8 @@ #define VOLTAGE_CHECK_INTERVAL 288 // How often the tag should do a battery voltage check (multiplied by LONG_DATAREQ_INTERVAL) #define BATTERY_VOLTAGE_MINIMUM 2450 // 2600 or below is the best we can do on the EPD +#define MAX_RETURN_DATA_ATTEMPTS 15 + // power saving when no AP's were found (scanning every X) #define VOLTAGEREADING_DURING_SCAN_INTERVAL 2 // how often we should read voltages; this is done every scan attempt in interval bracket 3 #define INTERVAL_1_TIME 3600UL // Try every hour diff --git a/zbs243_Tag_FW/proto.h b/zbs243_Tag_FW/proto.h deleted file mode 120000 index fed53c0e..00000000 --- a/zbs243_Tag_FW/proto.h +++ /dev/null @@ -1 +0,0 @@ -../zbs243_shared/proto.h \ No newline at end of file diff --git a/zbs243_Tag_FW/settings.c b/zbs243_Tag_FW/settings.c index 4e0dd0aa..12caa628 100755 --- a/zbs243_Tag_FW/settings.c +++ b/zbs243_Tag_FW/settings.c @@ -1,3 +1,4 @@ +#define __packed #include "settings.h" #include @@ -7,10 +8,13 @@ #include #include + #include "asmUtil.h" #include "powermgt.h" #include "printf.h" #include "syncedproto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" struct tagsettings __xdata tagSettings = {0}; extern uint8_t __xdata blockXferBuffer[]; diff --git a/zbs243_Tag_FW/settings.h b/zbs243_Tag_FW/settings.h index 734bd403..3bd820fd 100755 --- a/zbs243_Tag_FW/settings.h +++ b/zbs243_Tag_FW/settings.h @@ -3,11 +3,13 @@ #include -#define FW_VERSION 20 // version number (max 2.5.5 :) ) -#define FW_VERSION_SUFFIX "-DSLP" // suffix, like -RC1 or whatever. +#define FW_VERSION 21 // version number (max 2.5.5 :) ) +#define FW_VERSION_SUFFIX "-RET" // suffix, like -RC1 or whatever. // #define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers // #define PRINT_LUT // uncomment if you want the tag to print the LUT for the current temperature bracket +// #define ENABLE_RETURN_DATA // enables the tag to send blocks of data back. Enabling this costs about 4 IRAM bytes + #define SETTINGS_STRUCT_VERSION 0x01 #define DEFAULT_SETTING_FASTBOOT 0 @@ -17,6 +19,7 @@ #define DEFAULT_SETTING_LOWBATSYMBOL 1 #define DEFAULT_SETTING_NORFSYMBOL 1 +/* struct tagsettings { uint8_t settingsVer; // the version of the struct as written to the infopage uint8_t enableFastBoot; // default 0; if set, it will skip splashscreen @@ -31,6 +34,7 @@ struct tagsettings { uint16_t minimumCheckInTime; // defaults to BASE_INTERVAL from powermgt.h uint8_t fixedChannel; // default 0; if set to a valid channel number, the tag will stick to that channel } __packed; +*/ extern struct tagsettings tagSettings; diff --git a/zbs243_Tag_FW/syncedproto.c b/zbs243_Tag_FW/syncedproto.c index 7cb8072f..4efbb641 100755 --- a/zbs243_Tag_FW/syncedproto.c +++ b/zbs243_Tag_FW/syncedproto.c @@ -16,7 +16,8 @@ #include "i2cdevices.h" #include "powermgt.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" #include "radio.h" #include "screen.h" #include "settings.h" @@ -50,7 +51,7 @@ uint8_t __xdata currentChannel = 0; static uint8_t __xdata inBuffer[128] = {0}; static uint8_t __xdata outBuffer[128] = {0}; -extern void executeCommand(uint8_t cmd); // this is defined in main.c +extern void executeCommand(uint8_t cmd); // this is defined in main.c // tools static uint8_t __xdata getPacketType(const void *__xdata buffer) { @@ -251,6 +252,50 @@ struct AvailDataInfo *__xdata getShortAvailDataInfo() { dataReqLastAttempt = DATA_REQ_MAX_ATTEMPTS; return NULL; } + +#ifdef ENABLE_RETURN_DATA +static void sendTagReturnDataPacket(const uint8_t *data, uint8_t len, uint8_t type) { + struct MacFrameBcast __xdata *txframe = (struct MacFrameBcast *)(outBuffer + 1); + memset(outBuffer, 0, sizeof(struct MacFrameBcast) + sizeof(struct AvailDataReq) + 2 + 4); + struct tagReturnData *__xdata trd = (struct tagReturnData *)(outBuffer + 2 + sizeof(struct MacFrameBcast)); + outBuffer[0] = sizeof(struct MacFrameBcast) + 11 + len + 1 + 2; + outBuffer[sizeof(struct MacFrameBcast) + 1] = PKT_TAG_RETURN_DATA; + memcpy(txframe->src, mSelfMac, 8); + txframe->fcs.frameType = 1; + txframe->fcs.ackReqd = 1; + txframe->fcs.destAddrType = 2; + txframe->fcs.srcAddrType = 3; + txframe->seq = seq++; + txframe->dstPan = PROTO_PAN_ID; + txframe->dstAddr = 0xFFFF; + txframe->srcPan = PROTO_PAN_ID; + memcpy(trd->data, data, len); + trd->dataType = type; + memcpy(&trd->dataVer, mSelfMac, 8); + memcpy(&trd->dataVer, data, 4); + addCRC(trd, 11 + len); + commsTxNoCpy(outBuffer); +} + +bool sendTagReturnData(uint8_t __xdata *data, uint8_t len, uint8_t type) { + radioRxEnable(true, true); + uint32_t __xdata t; + for (uint8_t c = 0; c < MAX_RETURN_DATA_ATTEMPTS; c++) { + sendTagReturnDataPacket(data, len, type); + t = timerGet() + (TIMER_TICKS_PER_MS * DATA_REQ_RX_WINDOW_SIZE); + while (timerGet() < t) { + int8_t __xdata ret = commsRxUnencrypted(inBuffer); + if (ret > 1) { + if ((getPacketType(inBuffer) == PKT_TAG_RETURN_DATA_ACK) && (pktIsUnicast(inBuffer))) { + return true; + } + } + } + } + return false; +} +#endif + static bool processBlockPart(const struct blockPart *bp) { uint16_t __xdata start = bp->blockPart * BLOCK_PART_DATA_SIZE; uint16_t __xdata size = BLOCK_PART_DATA_SIZE; diff --git a/zbs243_Tag_FW/syncedproto.h b/zbs243_Tag_FW/syncedproto.h index e3be548d..5f6287b7 100755 --- a/zbs243_Tag_FW/syncedproto.h +++ b/zbs243_Tag_FW/syncedproto.h @@ -2,7 +2,7 @@ #define SYNCED_H #include -//#include "settings.h" +#include "settings.h" extern uint8_t __xdata mSelfMac[]; extern uint8_t __xdata currentChannel; @@ -13,6 +13,11 @@ extern uint8_t __xdata curImgSlot; extern void setupRadio(void); extern void killRadio(void); + +#ifdef ENABLE_RETURN_DATA +extern bool sendTagReturnData(uint8_t __xdata *data, uint8_t len, uint8_t type); +#endif + void dump(const uint8_t *__xdata a, const uint16_t __xdata l); extern struct AvailDataInfo *__xdata getAvailDataInfo(); extern struct AvailDataInfo *__xdata getShortAvailDataInfo(); diff --git a/zbs243_Tag_FW/userinterface.c b/zbs243_Tag_FW/userinterface.c index febb7601..912ff923 100755 --- a/zbs243_Tag_FW/userinterface.c +++ b/zbs243_Tag_FW/userinterface.c @@ -14,7 +14,8 @@ #include "lut.h" #include "powermgt.h" #include "printf.h" -#include "proto.h" +#include "../oepl-definitions.h" +#include "../oepl-proto.h" #include "screen.h" #include "settings.h" #include "sleep.h" diff --git a/zbs243_shared/board/zbs154_ssd1619/board.h b/zbs243_shared/board/zbs154_ssd1619/board.h index 46d255ab..11ff717f 100755 --- a/zbs243_shared/board/zbs154_ssd1619/board.h +++ b/zbs243_shared/board/zbs154_ssd1619/board.h @@ -2,7 +2,10 @@ #define _BOARD_H_ #include -#include "proto.h" + +#define __packed +#include "../oepl-definitions.h" + #include "spi.h" #define eepromByte spiByte diff --git a/zbs243_shared/board/zbs29_ssd1619/board.h b/zbs243_shared/board/zbs29_ssd1619/board.h index 9f1c06d7..08b56f04 100755 --- a/zbs243_shared/board/zbs29_ssd1619/board.h +++ b/zbs243_shared/board/zbs29_ssd1619/board.h @@ -2,7 +2,10 @@ #define _BOARD_H_ #include -#include "proto.h" + +#define __packed + +#include "../oepl-definitions.h" #include "spi.h" #define eepromByte spiByte diff --git a/zbs243_shared/board/zbs29_uc8151/board.h b/zbs243_shared/board/zbs29_uc8151/board.h index 7ec406f0..138a3139 100755 --- a/zbs243_shared/board/zbs29_uc8151/board.h +++ b/zbs243_shared/board/zbs29_uc8151/board.h @@ -2,9 +2,12 @@ #define _BOARD_H_ #include -#include "proto.h" #include "spi.h" +#define __packed +#include "../oepl-definitions.h" + + #define eepromByte spiByte #define eepromPrvSelect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 0; __asm__("nop\nnop\nnop\n"); } while(0) #define eepromPrvDeselect() do { __asm__("nop\nnop\nnop\n"); P1_1 = 1; __asm__("nop\nnop\nnop\n"); } while(0) diff --git a/zbs243_shared/board/zbs42_ssd1619/board.h b/zbs243_shared/board/zbs42_ssd1619/board.h index e1d5519b..5cd7517f 100755 --- a/zbs243_shared/board/zbs42_ssd1619/board.h +++ b/zbs243_shared/board/zbs42_ssd1619/board.h @@ -2,7 +2,8 @@ #define _BOARD_H_ #include -#include "proto.h" +#define __packed +#include "../oepl-definitions.h" #include "spi.h" #define eepromByte spiByte diff --git a/zbs243_shared/board/zbs_nodisplay/board.h b/zbs243_shared/board/zbs_nodisplay/board.h index c9bbe9a9..f2c8d399 100755 --- a/zbs243_shared/board/zbs_nodisplay/board.h +++ b/zbs243_shared/board/zbs_nodisplay/board.h @@ -2,7 +2,11 @@ #define _BOARD_H_ #include -#include "proto.h" + +#define __packed + +#include "../oepl-definitions.h" + #include "spi.h" #define HAS_EEPROM 0 diff --git a/zbs243_shared/board/zbs_segmented_uk/board.h b/zbs243_shared/board/zbs_segmented_uk/board.h index 7deb17ee..35d884ca 100755 --- a/zbs243_shared/board/zbs_segmented_uk/board.h +++ b/zbs243_shared/board/zbs_segmented_uk/board.h @@ -2,7 +2,8 @@ #define _BOARD_H_ #include -#include "proto.h" +#define __packed +#include "../oepl-definitions.h" #include "spi.h" #define HAS_EEPROM 0 diff --git a/zbs243_shared/proto.h b/zbs243_shared/proto.h deleted file mode 100755 index 161a761c..00000000 --- a/zbs243_shared/proto.h +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef _PROTO_H_ -#define _PROTO_H_ -#define __packed -#include - -#include "../tag_types.h" - -enum TagScreenType { - TagScreenEink_BW_1bpp, - TagScreenEink_BW_2bpp, - TagScreenEink_BW_4bpp, - TagScreenEink_BWY_only, // 2bpp, but only 3 colors (BW?Y) - TagScreenEink_BWY_2bpp, - TagScreenEink_BWY_4bpp, - TagScreenEink_BWR_only, // 2bpp, but only 3 colors (BW?R) - TagScreenEink_BWR_2bpp, - TagScreenEink_BWR_4bpp, - - TagScreenEink_BWY_3bpp, - TagScreenEink_BWR_3bpp, - TagScreenEink_BW_3bpp, - - TagScreenPersistentLcd_1bpp, - - TagScreenEink_BWY_5colors, - TagScreenEink_BWR_5colors, - - TagScreenEink_BWY_6colors, - TagScreenEink_BWR_6colors, - - TagScreenTypeOther = 0x7f, -}; - -#ifndef __packed -#define __packed __attribute__((packed)) -#endif - -#define PROTO_PAN_ID (0x4447) // PAN ID compression shall be used - -#define RADIO_MAX_PACKET_LEN (125) // useful payload, not including the crc - -#define ADDR_MODE_NONE (0) -#define ADDR_MODE_SHORT (2) -#define ADDR_MODE_LONG (3) - -#define FRAME_TYPE_BEACON (0) -#define FRAME_TYPE_DATA (1) -#define FRAME_TYPE_ACK (2) -#define FRAME_TYPE_MAC_CMD (3) - -#define SHORT_MAC_UNUSED (0x10000000UL) // for radioRxFilterCfg's myShortMac - -struct MacFcs { - uint8_t frameType : 3; - uint8_t secure : 1; - uint8_t framePending : 1; - uint8_t ackReqd : 1; - uint8_t panIdCompressed : 1; - uint8_t rfu1 : 1; - uint8_t rfu2 : 2; - uint8_t destAddrType : 2; - uint8_t frameVer : 2; - uint8_t srcAddrType : 2; -} __packed; - -struct MacFrameFromMaster { - struct MacFcs fcs; - uint8_t seq; - uint16_t pan; - uint8_t dst[8]; - uint16_t from; -} __packed; - -struct MacFrameNormal { - struct MacFcs fcs; - uint8_t seq; - uint16_t pan; - uint8_t dst[8]; - uint8_t src[8]; -} __packed; - -struct MacFrameBcast { - struct MacFcs fcs; - uint8_t seq; - uint16_t dstPan; - uint16_t dstAddr; - uint16_t srcPan; - uint8_t src[8]; -} __packed; - -#define PKT_AVAIL_DATA_SHORTREQ 0xE3 -#define PKT_AVAIL_DATA_REQ 0xE5 -#define PKT_AVAIL_DATA_INFO 0xE6 -#define PKT_BLOCK_PARTIAL_REQUEST 0xE7 -#define PKT_BLOCK_REQUEST_ACK 0xE9 -#define PKT_BLOCK_REQUEST 0xE4 -#define PKT_BLOCK_PART 0xE8 -#define PKT_XFER_COMPLETE 0xEA -#define PKT_XFER_COMPLETE_ACK 0xEB -#define PKT_CANCEL_XFER 0xEC -#define PKT_PING 0xED -#define PKT_PONG 0xEE - -struct AvailDataReq { - uint8_t checksum; - uint8_t lastPacketLQI; - int8_t lastPacketRSSI; - int8_t temperature; - uint16_t batteryMv; - uint8_t hwType; - uint8_t wakeupReason; - uint8_t capabilities; - uint16_t tagSoftwareVersion; - uint8_t currentChannel; - uint8_t customMode; - uint8_t reserved[8]; -} __packed; - -struct oldAvailDataReq { - uint8_t checksum; - uint8_t lastPacketLQI; - int8_t lastPacketRSSI; - int8_t temperature; - uint16_t batteryMv; - uint8_t hwType; - uint8_t wakeupReason; - uint8_t capabilities; -} __packed; - -struct AvailDataInfo { - uint8_t checksum; - uint64_t dataVer; // MD5 of potential traffic - uint32_t dataSize; - uint8_t dataType; - uint8_t dataTypeArgument; // extra specification or instruction for the tag (LUT to be used for drawing image) - uint16_t nextCheckIn; // when should the tag check-in again? Measured in minutes -} __packed; - -struct pendingData { - struct AvailDataInfo availdatainfo; - uint16_t attemptsLeft; - uint8_t targetMac[8]; -} __packed; - -struct blockPart { - uint8_t checksum; - uint8_t blockId; - uint8_t blockPart; - uint8_t data[]; -} __packed; - -struct blockData { - uint16_t size; - uint16_t checksum; - uint8_t data[]; -} __packed; - -struct burstMacData { - uint16_t offset; - uint8_t targetMac[8]; -} __packed; - -#define BLOCK_PART_DATA_SIZE 99 -#define BLOCK_MAX_PARTS 42 -#define BLOCK_DATA_SIZE 4096UL -#define BLOCK_XFER_BUFFER_SIZE BLOCK_DATA_SIZE + sizeof(struct blockData) -#define BLOCK_REQ_PARTS_BYTES 6 - -struct blockRequest { - uint8_t checksum; - uint64_t ver; - uint8_t blockId; - uint8_t type; - uint8_t requestedParts[BLOCK_REQ_PARTS_BYTES]; -} __packed; - -struct blockRequestAck { - uint8_t checksum; - uint16_t pleaseWaitMs; -} __packed; - -struct espBlockRequest { - uint8_t checksum; - uint64_t ver; - uint8_t blockId; - uint8_t src[8]; -} __packed; - -struct espXferComplete { - uint8_t checksum; - uint8_t src[8]; -} __packed; - -struct espAvailDataReq { - uint8_t checksum; - uint8_t src[8]; - struct AvailDataReq adr; -} __packed; - -struct espSetChannelPower { - uint8_t checksum; - uint8_t channel; - uint8_t power; -} __packed; - -#define MACFMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" -#define MACCVT(x) ((const uint8_t*)(x))[7], ((const uint8_t*)(x))[6], ((const uint8_t*)(x))[5], ((const uint8_t*)(x))[4], ((const uint8_t*)(x))[3], ((const uint8_t*)(x))[2], ((const uint8_t*)(x))[1], ((const uint8_t*)(x))[0] - -#endif