For our new IoT project we need a synchronization module: a UDP Server (Qt5-C++, any SQL database) and a corresponding client (C based, limited recources) based on the nanopb implementation of googles Protocol Buffers.
The whole synchronization is always initiated by the client: in certain intervals the client will setup a request-ProtocolBuffers message, send it via UDP to the server and the server processes the request, fetches database results and sends back a response-UDP-packet containing the response-ProtocolBuffers-message.
There are 5 types of synchronization:
1.) state: simple transfer of a state struct to the server and update the corresponding database entry
2.) settings: request current settings from the database, apply them locally to a settings struct and send back the applied settings as confirmation to the server (which will be there handled similar to the state)
3.) tokens (similar to settings): request new tokens from the DB, apply them on the client, send back applied tokens and update database
4.) files: request file updates (based on versions in the settings), files should be transferred in 256bytes chunks and written locally using fopen(), fwrite(APPEND), fclose() making sure the local files are consistent, no chunk is missing or in the wrong order.
5.) logging: provide a function in the client which takes a snapshot of the state struct, e.g. every 5 seconds, appends it to a file "[login to view URL]" and after the file reaches a certain size, try to send the file to the server. In opposition to the "state" this should also work while the client is offline and just synchronize all the missed states when the client is online again.
The client software has to be written with very efficient use of resources in mind (nanopb provides herefore the callback based parsing of the messages) as the embedded target environment has a total RAM of 64kBytes.
Every functional block in the code should be commented with a short english description. Every source file with a longer descriptional text how to use the provided functionality.
There are some samples for the client attached which can be taken as startingpoint for developement.
For the server also exists a basic running proof of concept as a QT project, which can be handed out once agreed on the project to ease the startup phase.