mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 02:04:36 +01:00
ZBS Tag Return-data support
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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) {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../zbs243_shared/proto.h
|
||||
2
zbs243_Tag_FW/comms.c
Normal file → Executable file
2
zbs243_Tag_FW/comms.c
Normal file → Executable file
@@ -1,8 +1,6 @@
|
||||
#define __packed
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "proto.h"
|
||||
#include "asmUtil.h"
|
||||
#include "printf.h"
|
||||
#include "radio.h"
|
||||
|
||||
2
zbs243_Tag_FW/drawing.c
Normal file → Executable file
2
zbs243_Tag_FW/drawing.c
Normal file → Executable file
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../zbs243_shared/proto.h
|
||||
@@ -1,3 +1,4 @@
|
||||
#define __packed
|
||||
#include "settings.h"
|
||||
|
||||
#include <flash.h>
|
||||
@@ -7,10 +8,13 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#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[];
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define SYNCED_H
|
||||
|
||||
#include <stdint.h>
|
||||
//#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();
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "proto.h"
|
||||
|
||||
#define __packed
|
||||
#include "../oepl-definitions.h"
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#define eepromByte spiByte
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "proto.h"
|
||||
|
||||
#define __packed
|
||||
|
||||
#include "../oepl-definitions.h"
|
||||
#include "spi.h"
|
||||
|
||||
#define eepromByte spiByte
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#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)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "proto.h"
|
||||
#define __packed
|
||||
#include "../oepl-definitions.h"
|
||||
#include "spi.h"
|
||||
|
||||
#define eepromByte spiByte
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "proto.h"
|
||||
|
||||
#define __packed
|
||||
|
||||
#include "../oepl-definitions.h"
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#define HAS_EEPROM 0
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#define _BOARD_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "proto.h"
|
||||
#define __packed
|
||||
#include "../oepl-definitions.h"
|
||||
#include "spi.h"
|
||||
|
||||
#define HAS_EEPROM 0
|
||||
|
||||
@@ -1,209 +0,0 @@
|
||||
#ifndef _PROTO_H_
|
||||
#define _PROTO_H_
|
||||
#define __packed
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user