MCPcopy Create free account
hub / github.com/LowPowerLab/RFM69 / CheckForWirelessHEX

Function CheckForWirelessHEX

RFM69_OTA.cpp:47–72  ·  view source on GitHub ↗

=================================================================================================================== CheckForWirelessHEX() - Checks whether the last message received was a wireless programming request handshake If so it will start the handshake protocol, receive the new HEX image and store it on the external flash chip, then reboot Assumes radio has been initialized and has just rec

Source from the content-addressed store, hash-verified

45// Assumes flash is an external SPI flash memory chip that has been initialized
46//===================================================================================================================
47void CheckForWirelessHEX(RFM69& radio, SPIFlash& flash, uint8_t DEBUG, uint8_t LEDpin)
48{
49 //special FLASH command, enter a FLASH image exchange sequence
50 if (radio.DATALEN >= 4 && radio.DATA[0]=='F' && radio.DATA[1]=='L' && radio.DATA[2]=='X' && radio.DATA[3]=='?')
51 {
52 uint16_t remoteID = radio.SENDERID;
53 if (radio.DATALEN == 7 && radio.DATA[4]=='E' && radio.DATA[5]=='O' && radio.DATA[6]=='F')
54 { //sender must have not received EOF ACK so just resend
55 radio.send(remoteID, "FLX?OK",6);
56 }
57#ifdef SHIFTCHANNEL
58 else if (HandleWirelessHEXDataWrapper(radio, remoteID, flash, DEBUG, LEDpin))
59#else
60 else if (HandleWirelessHEXData(radio, remoteID, flash, DEBUG, LEDpin))
61#endif
62 {
63 if (DEBUG) Serial.print(F("FLASH IMG TRANSMISSION SUCCESS!\n"));
64 resetUsingWatchdog(DEBUG);
65 }
66 else
67 {
68 if (DEBUG) Serial.print("Timeout/Error, erasing written data ... ");
69 //flash.blockErase32K(0); //clear any written data in first 32K block
70 if (DEBUG) Serial.println(F("DONE"));
71 }
72 }
73}
74
75

Callers

nothing calls this directly

Calls 4

HandleWirelessHEXDataFunction · 0.85
resetUsingWatchdogFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected