removd bitfield as it turned out to be inefficient

This commit is contained in:
Jelmer
2023-02-04 02:20:22 +01:00
parent 2be1b7d40e
commit 8cc5ae23af
7 changed files with 54 additions and 24 deletions

View File

@@ -40,7 +40,7 @@ struct MacFrameBcast {
uint16_t srcPan;
uint8_t src[8];
} __packed;
#define PKT_AVAIL_DATA_REQ_SHORT 0xE4
#define PKT_AVAIL_DATA_REQ 0xE5
#define PKT_AVAIL_DATA_INFO 0xE6
#define PKT_BLOCK_PARTIAL_REQUEST 0xE7
@@ -55,14 +55,15 @@ struct MacFrameBcast {
struct AvailDataReq {
uint8_t checksum;
uint8_t lastPacketLQI : 7;
uint8_t lastPacketRSSI : 7; // is negative
int8_t temperature : 7; // zero if not reported/not supported to be reported. else, this minus CHECKIN_TEMP_OFFSET is temp in degrees C
uint16_t batteryMv : 12;
uint8_t hwType : 5; // 32 types of tags supported
uint8_t wakeupReason : 2; // supports 4 types of wakeup reasons
uint8_t capabilities;
} __packed; // 7 bytes
uint8_t lastPacketLQI;
int8_t lastPacketRSSI;
int8_t temperature;
uint16_t batteryMv;
uint8_t hwType;
uint8_t wakeupReason;
uint8_t capabilities; // undefined, as of now
} __packed;
#define DATATYPE_NOUPDATE 0
#define DATATYPE_IMG 1
@@ -73,8 +74,8 @@ struct AvailDataInfo {
uint8_t checksum;
uint64_t dataVer; // MD5 of potential traffic
uint32_t dataSize;
uint8_t dataType : 4; // allows for 16 different datatypes
uint8_t dataTypeArgument : 4; // extra specification or instruction for the tag (LUT to be used for drawing image)
uint8_t dataType; // allows for 16 different datatypes
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;

View File

@@ -35,6 +35,7 @@
void epdSetup();
void epdEnterSleep();
uint16_t epdGetBattery();
void setWindowX(uint16_t start, uint16_t end);
void setWindowY(uint16_t start, uint16_t end);
@@ -48,7 +49,6 @@ void drawNoWait();
void epdWaitRdy();
void drawLineHorizontal(bool color, uint16_t x1, uint16_t x2, uint16_t y);
void drawLineVertical(bool color, uint16_t x, uint16_t y1, uint16_t y2);
void beginFullscreenImage();
void beginWriteFramebuffer(bool color);
void endWriteFramebuffer();

View File

@@ -20,6 +20,8 @@
//#define DEBUG_MODE
uint8_t showChannelSelect() {
uint8_t __xdata result[16];
memset(result, 0, sizeof(result));
@@ -49,7 +51,6 @@ uint8_t showChannelSelect() {
mLastLqi = highestLqi;
return highestSlot;
}
void mainProtocolLoop(void) {
clockingAndIntsInit();
timerInit();
@@ -83,6 +84,8 @@ void mainProtocolLoop(void) {
initPowerSaving();
#ifndef DEBUG_MODE
// show the splashscreen
getExtraData();
showSplashScreen();
eepromDeepPowerDown();

View File

@@ -30,12 +30,25 @@ uint8_t __xdata dataReqLastAttempt = 0;
uint16_t __xdata nextCheckInFromAP = 0;
uint8_t __xdata wakeUpReason = 0;
extern int8_t adcSampleTemperature(void); //in degrees C
void initPowerSaving() {
for (uint8_t c = 0; c < POWER_SAVING_SMOOTHING; c++) {
dataReqAttemptArr[c] = INTERVAL_BASE;
}
}
int8_t __xdata temperature = 0;
uint16_t __xdata batteryVoltage = 0;
void getExtraData(){
batteryVoltage = epdGetBattery();
temperature = adcSampleTemperature();
pr("temp = %d volt = %d\n", temperature, batteryVoltage);
}
// init/sleep
void initAfterWake() {
clockingAndIntsInit();
@@ -45,6 +58,7 @@ void initAfterWake() {
epdEnterSleep();
irqsOn();
boardInitStage2();
getExtraData();
initRadio();
}
void doSleep(uint32_t __xdata t) {

View File

@@ -28,9 +28,15 @@ extern void initAfterWake();
extern void doSleep(uint32_t __xdata t);
extern uint16_t getNextSleep();
extern void initPowerSaving();
extern void getExtraData();
extern uint8_t __xdata wakeUpReason;
extern uint16_t __xdata nextCheckInFromAP;
extern uint8_t __xdata dataReqLastAttempt;
extern int8_t __xdata temperature;
extern uint16_t __xdata batteryVoltage;
#endif

View File

@@ -90,6 +90,7 @@ struct MacFrameBcast {
uint8_t src[8];
} __packed;
#define PKT_AVAIL_DATA_REQ_SHORT 0xE4
#define PKT_AVAIL_DATA_REQ 0xE5
#define PKT_AVAIL_DATA_INFO 0xE6
#define PKT_BLOCK_PARTIAL_REQUEST 0xE7
@@ -104,14 +105,15 @@ struct MacFrameBcast {
struct AvailDataReq {
uint8_t checksum;
uint8_t lastPacketLQI : 7;
uint8_t lastPacketRSSI : 7; // is negative
int8_t temperature : 7; // zero if not reported/not supported to be reported. else, this minus CHECKIN_TEMP_OFFSET is temp in degrees C
uint16_t batteryMv : 12;
uint8_t hwType : 5; // 32 types of tags supported
uint8_t wakeupReason : 2; // supports 4 types of wakeup reasons
uint8_t capabilities;
} __packed; // 7 bytes
uint8_t lastPacketLQI;
int8_t lastPacketRSSI;
int8_t temperature;
uint16_t batteryMv;
uint8_t hwType;
uint8_t wakeupReason;
uint8_t capabilities; // undefined, as of now
} __packed;
#define DATATYPE_NOUPDATE 0
#define DATATYPE_IMG 1
@@ -122,11 +124,12 @@ struct AvailDataInfo {
uint8_t checksum;
uint64_t dataVer; // MD5 of potential traffic
uint32_t dataSize;
uint8_t dataType : 4; // allows for 16 different datatypes
uint8_t dataTypeArgument : 4; // extra specification or instruction for the tag (LUT to be used for drawing image)
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 blockPart {
uint8_t checksum;
uint8_t blockId;

View File

@@ -202,7 +202,10 @@ void sendAvailDataReq() {
// TODO: send some (more) meaningful data
availreq->hwType = HW_TYPE;
availreq->wakeupReason = wakeUpReason;
availreq->lastPacketRSSI = (uint8_t)(-1*mLastRSSI);
availreq->lastPacketLQI = mLastLqi;
availreq->temperature = temperature;
availreq->batteryMv = batteryVoltage;
addCRC(availreq, sizeof(struct AvailDataReq));
commsTxNoCpy(outBuffer);
}