mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 07:06:36 +01:00
some mods in AP-ESP32 protocol
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
19
tag_types.h
Executable file
19
tag_types.h
Executable file
@@ -0,0 +1,19 @@
|
||||
#define SOLUM_154_033 0
|
||||
#define SOLUM_29_033 1
|
||||
#define SOLUM_42_033 2
|
||||
#define SOLUM_SEG_UK 0xF0
|
||||
#define SOLUM_NODISPLAY 0xFF
|
||||
|
||||
#define CAPABILITY_HAS_WAKE_BUTTON 0x20
|
||||
#define CAPABILITY_HAS_NFC 0x40
|
||||
#define CAPABILITY_NFC_WAKE 0x80
|
||||
|
||||
#define DATATYPE_NOUPDATE 0
|
||||
#define DATATYPE_IMG_BMP 2
|
||||
#define DATATYPE_FW_UPDATE 3
|
||||
#define DATATYPE_IMG_DIFF 0x10 // always 1BPP
|
||||
#define DATATYPE_IMG_RAW_1BPP 0x20 // 2888 bytes for 1.54" / 4736 2.9" / 15000 4.2"
|
||||
#define DATATYPE_IMG_RAW_2BPP 0x21 // 5776 bytes for 1.54" / 9472 2.9" / 30000 4.2"
|
||||
#define DATATYPE_IMG_RAW_1BPP_DIRECT 0x3F // only for 1.54", don't write to EEPROM, but straightaway to the EPD
|
||||
#define DATATYPE_NFC_RAW_CONTENT 0xA0 // raw memory content for the NT3H1101
|
||||
#define DATATYPE_NFC_URL_DIRECT 0xA1 // URL format for NT3H1101
|
||||
@@ -87,7 +87,7 @@ void epdShowRun() {
|
||||
epdPrintBegin(16, 55, EPD_DIRECTION_X, EPD_SIZE_DOUBLE, EPD_COLOR_BLACK);
|
||||
epdpr("AP Mode");
|
||||
epdPrintEnd();
|
||||
drawNoWait();
|
||||
draw();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,8 @@ $stackdisturbed = false;
|
||||
$mem = checkmem();
|
||||
while(1){
|
||||
$errlist = array();
|
||||
exec("make BUILD=zbs154v033 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
|
||||
//exec("make BUILD=zbs154v033 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
|
||||
exec("make BUILD=zbs_segmented_uk CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
|
||||
if(checkmem()!=$mem){
|
||||
$stackdisturbed = true;
|
||||
echo "Stack size was $mem, is now ".checkmem()." !!!\n";
|
||||
|
||||
@@ -50,7 +50,7 @@ uint16_t epdByteCounter = 0;
|
||||
void epdWriteByte(uint8_t b) {
|
||||
epdSend(b);
|
||||
epdByteCounter++;
|
||||
// check if we need to switch to a
|
||||
// check if we need to switch to a
|
||||
if (epdByteCounter == (SCREEN_HEIGHT * SCREEN_WIDTH / 8)) {
|
||||
epdDeselect();
|
||||
endWriteFramebuffer();
|
||||
@@ -111,6 +111,7 @@ void fakePendingData(struct pendingData *pd) {
|
||||
}
|
||||
|
||||
void fakeTagCheckIn() {
|
||||
static bool __xdata firstboot = true;
|
||||
struct AvailDataReq *adr = (struct AvailDataReq *)radiorxbuffer;
|
||||
|
||||
memset(adr, 0, sizeof(struct AvailDataReq));
|
||||
@@ -118,7 +119,12 @@ void fakeTagCheckIn() {
|
||||
adr->hwType = HW_TYPE;
|
||||
adr->lastPacketLQI = 100;
|
||||
adr->lastPacketRSSI = 100;
|
||||
adr->wakeupReason = 0;
|
||||
if (firstboot) {
|
||||
adr->wakeupReason = 0xFC;
|
||||
firstboot = false;
|
||||
} else {
|
||||
adr->wakeupReason = 0;
|
||||
}
|
||||
addCRC(adr, sizeof(struct AvailDataReq));
|
||||
espNotifyAvailDataReq(adr, fakeTagMac);
|
||||
}
|
||||
|
||||
@@ -24,37 +24,13 @@
|
||||
#include "emulateTag.h"
|
||||
#endif
|
||||
|
||||
#define MAX_PENDING_MACS 50
|
||||
#define MAX_PENDING_MACS 55
|
||||
#define HOUSEKEEPING_INTERVAL 60UL
|
||||
|
||||
struct pendingData __xdata pendingDataArr[MAX_PENDING_MACS];
|
||||
|
||||
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 TIMER_TICKS_PER_MS 1333UL
|
||||
uint16_t __xdata version = 0x0012;
|
||||
// VERSION GOES HERE!
|
||||
uint16_t __xdata version = 0x0013;
|
||||
|
||||
#define RAW_PKT_PADDING 2
|
||||
|
||||
@@ -65,13 +41,6 @@ uint8_t __xdata radiorxbuffer[128];
|
||||
|
||||
uint8_t __xdata mSelfMac[8];
|
||||
|
||||
// serial stuff
|
||||
uint8_t __xdata cmdbuffer[4];
|
||||
uint8_t __xdata RXState = 0;
|
||||
uint8_t __xdata serialbuffer[48];
|
||||
uint8_t *__xdata serialbufferp;
|
||||
uint8_t __xdata bytesRemain = 0;
|
||||
|
||||
static uint32_t __xdata housekeepingTimer;
|
||||
|
||||
struct blockRequest __xdata requestedData = {0}; // holds which data was requested by the tag
|
||||
@@ -94,12 +63,14 @@ uint32_t __xdata lastBlockRequest = 0;
|
||||
uint8_t __xdata lastBlockMac[8];
|
||||
|
||||
uint8_t __xdata curChannel = 11;
|
||||
uint8_t __xdata curPower = 10;
|
||||
|
||||
uint8_t __xdata curPendingData = 0;
|
||||
uint8_t __xdata curNoUpdate = 0;
|
||||
|
||||
void sendXferCompleteAck(uint8_t *dst);
|
||||
void sendCancelXfer(uint8_t *dst);
|
||||
void espNotifyAPInfo();
|
||||
|
||||
// tools
|
||||
void addCRC(void *p, uint8_t len) {
|
||||
@@ -232,6 +203,12 @@ void countSlots() {
|
||||
|
||||
extern uint8_t *__idata blockp;
|
||||
void processSerial(uint8_t lastchar) {
|
||||
static uint8_t __xdata cmdbuffer[4];
|
||||
static uint8_t __xdata RXState = 0;
|
||||
static uint8_t __xdata serialbuffer[48];
|
||||
static uint8_t *__xdata serialbufferp;
|
||||
static uint8_t __xdata bytesRemain = 0;
|
||||
|
||||
static uint32_t __xdata lastSerial = 0;
|
||||
if ((timerGet() - lastSerial) > (TIMER_TICKS_PER_MS * 25)) {
|
||||
RXState = ZBS_RX_WAIT_HEADER;
|
||||
@@ -272,16 +249,18 @@ void processSerial(uint8_t lastchar) {
|
||||
serialbufferp = serialbuffer;
|
||||
break;
|
||||
}
|
||||
if (strncmp(cmdbuffer, "VER?", 4) == 0) {
|
||||
pr("VER>%04X\n", version);
|
||||
if (strncmp(cmdbuffer, "NFO?", 4) == 0) {
|
||||
pr("ACK>");
|
||||
espNotifyAPInfo();
|
||||
}
|
||||
if (strncmp(cmdbuffer, "RDY?", 4) == 0) {
|
||||
pr("RDY>");
|
||||
pr("ACK>");
|
||||
}
|
||||
if (strncmp(cmdbuffer, "RSET", 4) == 0) {
|
||||
pr("ACK>");
|
||||
timerDelay(TIMER_TICKS_PER_MS * 100);
|
||||
wdtDeviceReset();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ZBS_RX_WAIT_SDA:
|
||||
@@ -354,6 +333,7 @@ void processSerial(uint8_t lastchar) {
|
||||
goto SCPfailed;
|
||||
SCPchannelFound:
|
||||
curChannel = scp->channel;
|
||||
curPower = scp->power;
|
||||
radioSetChannel(scp->channel);
|
||||
radioSetTxPower(scp->power);
|
||||
radioRxEnable(true, true);
|
||||
@@ -424,6 +404,19 @@ void espNotifyTimeOut(const uint8_t *src) {
|
||||
uartTx(((uint8_t *)exfc)[c]);
|
||||
}
|
||||
}
|
||||
void espNotifyAPInfo() {
|
||||
pr("TYP>%02X\n", HW_TYPE);
|
||||
pr("VER>%04X\n", version);
|
||||
pr("MAC>%02X%02X", mSelfMac[0], mSelfMac[1]);
|
||||
pr("%02X%02X", mSelfMac[2], mSelfMac[3]);
|
||||
pr("%02X%02X", mSelfMac[4], mSelfMac[5]);
|
||||
pr("%02X%02X\n", mSelfMac[6], mSelfMac[7]);
|
||||
pr("ZCH>%02X\n", curChannel);
|
||||
pr("ZPW>%02X\n", curPower);
|
||||
countSlots();
|
||||
pr("PEN>%02X\n", curPendingData);
|
||||
pr("NOP>%02X\n", curNoUpdate);
|
||||
}
|
||||
|
||||
// process data from tag
|
||||
void processBlockRequest(const uint8_t *buffer, uint8_t forceBlockDownload) {
|
||||
@@ -726,22 +719,20 @@ void main(void) {
|
||||
radioSetChannel(curChannel);
|
||||
radioSetTxPower(10);
|
||||
radioRxEnable(true, true);
|
||||
|
||||
pr("RDY>\n");
|
||||
|
||||
timerDelay(TIMER_TICKS_PER_MS * 100);
|
||||
#if (HAS_SCREEN == 1)
|
||||
epdShowRun();
|
||||
#endif
|
||||
|
||||
pr("RES>\n");
|
||||
pr("RDY>\n");
|
||||
#if (AP_EMULATE_TAG == 1)
|
||||
fakeTagCheckIn();
|
||||
#endif
|
||||
|
||||
housekeepingTimer = timerGet();
|
||||
|
||||
pr("MAC>%02X%02X", mSelfMac[0], mSelfMac[1]);
|
||||
pr("%02X%02X", mSelfMac[2], mSelfMac[3]);
|
||||
pr("%02X%02X", mSelfMac[4], mSelfMac[5]);
|
||||
pr("%02X%02X\n", mSelfMac[6], mSelfMac[7]);
|
||||
|
||||
uint16_t __xdata loopCount = 1;
|
||||
pr("VER>%04X\n", version);
|
||||
while (1) {
|
||||
while ((timerGet() - housekeepingTimer) < ((TIMER_TICKS_PER_SECOND * HOUSEKEEPING_INTERVAL) - 100 * TIMER_TICKS_PER_MS)) {
|
||||
int8_t ret = commsRxUnencrypted(radiorxbuffer);
|
||||
|
||||
47
zbs243_shared/proto.h
Normal file → Executable file
47
zbs243_shared/proto.h
Normal file → Executable file
@@ -3,6 +3,8 @@
|
||||
#define __packed
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../tag_types.h"
|
||||
|
||||
enum TagScreenType {
|
||||
TagScreenEink_BW_1bpp,
|
||||
TagScreenEink_BW_2bpp,
|
||||
@@ -29,11 +31,6 @@ enum TagScreenType {
|
||||
TagScreenTypeOther = 0x7f,
|
||||
};
|
||||
|
||||
#define SOLUM_154_033 0
|
||||
#define SOLUM_29_033 1
|
||||
#define SOLUM_42_033 2
|
||||
#define SOLUM_SEG_UK 0xF0
|
||||
#define SOLUM_NODISPLAY 0xFF
|
||||
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((packed))
|
||||
@@ -116,21 +113,6 @@ struct AvailDataReq {
|
||||
uint8_t capabilities; // undefined, as of now
|
||||
} __packed;
|
||||
|
||||
#define CAPABILITY_HAS_WAKE_BUTTON 0x20
|
||||
#define CAPABILITY_HAS_NFC 0x40
|
||||
#define CAPABILITY_NFC_WAKE 0x80
|
||||
|
||||
#define DATATYPE_NOUPDATE 0
|
||||
#define DATATYPE_IMG_BMP 2
|
||||
#define DATATYPE_FW_UPDATE 3
|
||||
#define DATATYPE_IMG_DIFF 0x10 // always 1BPP
|
||||
#define DATATYPE_IMG_RAW_1BPP 0x20 // 2888 bytes for 1.54" / 4736 2.9" / 15000 4.2"
|
||||
#define DATATYPE_IMG_RAW_2BPP 0x21 // 5776 bytes for 1.54" / 9472 2.9" / 30000 4.2"
|
||||
#define DATATYPE_IMG_RAW_1BPP_DIRECT 0x3F // only for 1.54", don't write to EEPROM, but straightaway to the EPD
|
||||
#define DATATYPE_NFC_RAW_CONTENT 0xA0 // raw memory content for the NT3H1101
|
||||
#define DATATYPE_NFC_URL_DIRECT 0xA1 // URL format for NT3H1101
|
||||
|
||||
|
||||
|
||||
struct AvailDataInfo {
|
||||
uint8_t checksum;
|
||||
@@ -184,6 +166,31 @@ struct blockRequestAck {
|
||||
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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user