Hi, I am trying to create a new system message and system firmware call in Particle Photon that would send encrypted data to the local cloud (set-up in my linux machine) using the blocking_send routine. I successfully implemented the same and am sending sensor data at 10Hz (4274 bytes at a time) to the local cloud, which decrypts it and adds it to the repository. I gather all sensor data (using adafruit libraries) and call the firmware routine for encrypting and sending in the application loop.
However, after encrypting, sending, receiving and decrypting the data well for about 10-15 iterations of the loop, the device goes into error mode. it flashes the red SOS signal with 1 Blink in between (Hard Fault as per https://docs.particle.io/guide/getting-started/modes/photon/). Does anyone know why this happens? I have placed the system call code in the end of this post.
I also get the CryptoStream error on the local server as per shown below. Any help in this direction would be appreciated.
CryptoStream transform error TypeError: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
int SparkProtocol::mysend(const uint8_t *data, size_t length)
{
if (updating)
{
return false;
}
uint16_t msg_id = next_message_id();
size_t msglen = Messages::mysend(queue + 2, msg_id, data, length);
size_t wrapped_len = wrap(queue, msglen);
return (blocking_send(queue, wrapped_len));
}