mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 00:04:28 +01:00
Update main.c
This commit is contained in:
@@ -149,7 +149,7 @@ uint8_t getBlockDataLength() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pendingdata slot stuff
|
// pendingdata slot stuff
|
||||||
int8_t findSlotForMac(const uint8_t *mac) {
|
int32_t findSlotForMac(const uint8_t *mac) {
|
||||||
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
||||||
if (memcmp(mac, ((uint8_t *) &(pendingDataArr[c].targetMac)), 8) == 0) {
|
if (memcmp(mac, ((uint8_t *) &(pendingDataArr[c].targetMac)), 8) == 0) {
|
||||||
if (pendingDataArr[c].attemptsLeft != 0) {
|
if (pendingDataArr[c].attemptsLeft != 0) {
|
||||||
@@ -159,7 +159,7 @@ int8_t findSlotForMac(const uint8_t *mac) {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int8_t findFreeSlot() {
|
int32_t findFreeSlot() {
|
||||||
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
||||||
if (pendingDataArr[c].attemptsLeft == 0) {
|
if (pendingDataArr[c].attemptsLeft == 0) {
|
||||||
return c;
|
return c;
|
||||||
@@ -167,7 +167,7 @@ int8_t findFreeSlot() {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int8_t findSlotForVer(const uint8_t *ver) {
|
int32_t findSlotForVer(const uint8_t *ver) {
|
||||||
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
for (uint8_t c = 0; c < MAX_PENDING_MACS; c++) {
|
||||||
if (memcmp(ver, ((uint8_t *) &(pendingDataArr[c].availdatainfo.dataVer)), 8) == 0) {
|
if (memcmp(ver, ((uint8_t *) &(pendingDataArr[c].availdatainfo.dataVer)), 8) == 0) {
|
||||||
if (pendingDataArr[c].attemptsLeft != 0) return c;
|
if (pendingDataArr[c].attemptsLeft != 0) return c;
|
||||||
@@ -176,14 +176,14 @@ int8_t findSlotForVer(const uint8_t *ver) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
void deleteAllPendingDataForVer(const uint8_t *ver) {
|
void deleteAllPendingDataForVer(const uint8_t *ver) {
|
||||||
int8_t slot = -1;
|
int32_t slot = -1;
|
||||||
do {
|
do {
|
||||||
slot = findSlotForVer(ver);
|
slot = findSlotForVer(ver);
|
||||||
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
||||||
} while (slot != -1);
|
} while (slot != -1);
|
||||||
}
|
}
|
||||||
void deleteAllPendingDataForMac(const uint8_t *mac) {
|
void deleteAllPendingDataForMac(const uint8_t *mac) {
|
||||||
int8_t slot = -1;
|
int32_t slot = -1;
|
||||||
do {
|
do {
|
||||||
slot = findSlotForMac(mac);
|
slot = findSlotForMac(mac);
|
||||||
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
||||||
@@ -314,7 +314,7 @@ void processSerial(uint8_t lastchar) {
|
|||||||
if (bytesRemain == 0) {
|
if (bytesRemain == 0) {
|
||||||
if (checkCRC(serialbuffer, sizeof(struct pendingData))) {
|
if (checkCRC(serialbuffer, sizeof(struct pendingData))) {
|
||||||
struct pendingData *pd = (struct pendingData *) serialbuffer;
|
struct pendingData *pd = (struct pendingData *) serialbuffer;
|
||||||
int8_t slot = findSlotForMac(pd->targetMac);
|
int32_t slot = findSlotForMac(pd->targetMac);
|
||||||
if (slot == -1) slot = findFreeSlot();
|
if (slot == -1) slot = findFreeSlot();
|
||||||
if (slot != -1) {
|
if (slot != -1) {
|
||||||
memcpy(&(pendingDataArr[slot]), serialbuffer, sizeof(struct pendingData));
|
memcpy(&(pendingDataArr[slot]), serialbuffer, sizeof(struct pendingData));
|
||||||
@@ -624,7 +624,7 @@ void processXferComplete(uint8_t *buffer) {
|
|||||||
if (memcmp(lastAckMac, rxHeader->src, 8) != 0) {
|
if (memcmp(lastAckMac, rxHeader->src, 8) != 0) {
|
||||||
memcpy((void *) lastAckMac, (void *) rxHeader->src, 8);
|
memcpy((void *) lastAckMac, (void *) rxHeader->src, 8);
|
||||||
espNotifyXferComplete(rxHeader->src);
|
espNotifyXferComplete(rxHeader->src);
|
||||||
int8_t slot = findSlotForMac(rxHeader->src);
|
int32_t slot = findSlotForMac(rxHeader->src);
|
||||||
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
if (slot != -1) pendingDataArr[slot].attemptsLeft = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -788,7 +788,7 @@ void app_main(void) {
|
|||||||
housekeepingTimer = getMillis();
|
housekeepingTimer = getMillis();
|
||||||
while (1) {
|
while (1) {
|
||||||
while ((getMillis() - housekeepingTimer) < ((1000 * HOUSEKEEPING_INTERVAL) - 100)) {
|
while ((getMillis() - housekeepingTimer) < ((1000 * HOUSEKEEPING_INTERVAL) - 100)) {
|
||||||
int8_t ret = commsRxUnencrypted(radiorxbuffer);
|
int32_t ret = commsRxUnencrypted(radiorxbuffer);
|
||||||
if (ret > 1) {
|
if (ret > 1) {
|
||||||
led_flash(0);
|
led_flash(0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user