I have a working custom device integration for a device not currently supported by GpsGate. I am now trying to support FOTA (firmware upgrades over the air) for the device. The concept for this device is quite simple and primitive, the firmware file consist of x number of frames of 1032 bytes, binary data. For each frame successfully received by the device, the device returns OK or ERROR (and the frame number+total frames) until all frames are received. In case the device returns ERROR, the server should resend this frame.
Currently my implementation of the TranslateFromDevice() method of the Protocol class handles the sending of the firmware based on a special report type from the device.
Here are some fragments of the code:
// this part loads the firmware into a array of bytes. The size is about 45kbytes.
int frameSize = 1032;
byte firmwareData = File.ReadAllBytes(firmwareFileName);
// the frame to be sent to the device is sliced out of the array
byte frame = new byte[frameSize];
int currentFrame = 0;
Buffer.BlockCopy(firmwareData, currentFrame * frameSize, frame, 0, frameSize);
// this line sends the frame to the device
I can se the binary data being sent in the terminal, but the device is not recognizing the frame, and it does not respond as expected. I have a other stand-alone implementation based on node.js which works fine, so I can do successful FOTA there.
The question is if the ProtocolToDevice is a safe and correct way to send the binary data as one chunk to the device. Do you have any suggestions to what could be the cause of the device not recognizing the chunk of binary data (the frame of 1032 bytes)?
Do you recommend any other approach to this?
Thank you! Any ideas are welcome