File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -876,9 +876,16 @@ bool SparkProtocol::handle_received_message(void)
876876 unsigned int given_crc = queue[8 ] << 24 | queue[9 ] << 16 | queue[10 ] << 8 | queue[11 ];
877877 if (callback_calculate_crc (queue + 13 , len - 13 - queue[len - 1 ]) == given_crc)
878878 {
879- callback_save_firmware_chunk (queue + 13 , len - 13 - queue[len - 1 ]);
880- chunk_received (msg_to_send + 2 , token, ChunkReceivedCode::OK);
881- ++chunk_index;
879+ unsigned short next_chunk_index = callback_save_firmware_chunk (queue + 13 , len - 13 - queue[len - 1 ]);
880+ if (next_chunk_index > chunk_index)
881+ {
882+ chunk_received (msg_to_send + 2 , token, ChunkReceivedCode::OK);
883+ }
884+ else
885+ {
886+ chunk_missed (msg_to_send + 2 , next_chunk_index);
887+ }
888+ chunk_index = next_chunk_index;
882889 }
883890 else
884891 {
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ struct SparkCallbacks
6464 void (*prepare_for_firmware_update)(void );
6565 void (*finish_firmware_update)(void );
6666 long unsigned int (*calculate_crc)(unsigned char *buf, long unsigned int buflen);
67- void (*save_firmware_chunk)(unsigned char *buf, long unsigned int buflen);
67+ unsigned short (*save_firmware_chunk)(unsigned char *buf, long unsigned int buflen);
6868 void (*signal)(bool on);
6969 system_tick_t (*millis)();
7070};
@@ -142,7 +142,7 @@ class SparkProtocol
142142 void (*callback_prepare_for_firmware_update)(void );
143143 void (*callback_finish_firmware_update)(void );
144144 long unsigned int (*callback_calculate_crc)(unsigned char *buf, long unsigned int buflen);
145- void (*callback_save_firmware_chunk)(unsigned char *buf, long unsigned int buflen);
145+ unsigned short (*callback_save_firmware_chunk)(unsigned char *buf, long unsigned int buflen);
146146 void (*callback_signal)(bool on);
147147 system_tick_t (*callback_millis)();
148148
You can’t perform that action at this time.
0 commit comments