added support for changing channels

This commit is contained in:
Jelmer
2023-04-27 02:04:18 +02:00
parent aec5cc07e7
commit e3ea9121b4
3 changed files with 38 additions and 4 deletions

View File

@@ -13,6 +13,12 @@ struct espXferComplete {
uint8_t src[8];
} __packed;
struct espSetChannelPower {
uint8_t checksum;
uint8_t channel;
uint8_t power;
} __packed;
struct blockData {
uint16_t size;
uint16_t checksum;

View File

@@ -5,4 +5,6 @@ void zbsRxTask(void* parameter);
void sendCancelPending(struct pendingData* pending);
void sendDataAvail(struct pendingData* pending);
void Ping();
void Ping();
bool sendChannelPower(struct espSetChannelPower* scp);

View File

@@ -144,23 +144,42 @@ sdasend:
void sendCancelPending(struct pendingData* pending) {
if (!txStart()) return;
addCRC(pending, sizeof(struct pendingData));
addCRC(pending, sizeof(struct pendingData));
for (uint8_t attempt = 0; attempt < 5; attempt++) {
cmdReplyValue = CMD_REPLY_WAIT;
AP_SERIAL_PORT.print("CXD>");
for (uint8_t c = 0; c < sizeof(struct pendingData); c++) {
AP_SERIAL_PORT.write(((uint8_t*)pending)[c]);
}
if (waitCmdReply()) goto cxdsend;
if (waitCmdReply()) goto cxdsent;
AP_SERIAL_PORT.printf("CXD send failed in try %d\n", attempt);
}
AP_SERIAL_PORT.print("CXD failed to send...\n");
txEnd();
return;
cxdsend:
cxdsent:
txEnd();
}
bool sendChannelPower(struct espSetChannelPower* scp) {
if (!txStart()) return false;
addCRC(scp, sizeof(struct espSetChannelPower));
for (uint8_t attempt = 0; attempt < 5; attempt++) {
cmdReplyValue = CMD_REPLY_WAIT;
AP_SERIAL_PORT.print("SCP>");
for (uint8_t c = 0; c < sizeof(struct espSetChannelPower); c++) {
AP_SERIAL_PORT.write(((uint8_t*)scp)[c]);
}
if (waitCmdReply()) goto scpSent;
AP_SERIAL_PORT.printf("SCP send failed in try %d\n", attempt);
}
AP_SERIAL_PORT.print("SCP failed to send...\n");
txEnd();
return false;
scpSent:
txEnd();
return true;
}
uint64_t waitingForVersion = 0;
uint8_t crashcounter = 0;
uint16_t version;
@@ -372,6 +391,7 @@ void zbsRxTask(void* parameter) {
Serial.println("Performing firmware flash in about 10 seconds");
vTaskDelay(10000 / portTICK_PERIOD_MS);
performDeviceFlash();
//findOriginalFirmwareVersion();
} else {
Serial.println("I wasn't able to connect to a ZBS tag, trying to reboot the tag.");
rampTagPower(FLASHER_AP_POWER, false);
@@ -401,6 +421,12 @@ void zbsRxTask(void* parameter) {
}
} else if (!fsversion) {
Serial.println("No ZBS/Zigbee FW binary found on SPIFFS, please upload a zigbeebase000X.bin - format binary to enable flashing");
struct espSetChannelPower scp;
scp.channel = 20;
scp.power = 8;
sendChannelPower(&scp);
}
firstrun = false;
}