I’ve seen similar behavior to this before. I believe the callback needs to finish quickly, otherwise Mbed Cloud will reissue the POST message to the device, triggering your callback again.
I’d recommend having your callback only set a flag by using some of the RTOS synchronization features to trigger your longer-running analyze step in a separate thread. Here’s the docs page on the RTOS apis: https://os.mbed.com/docs/v5.7/reference/rtos.html
Hope that helps, let me know if you have further questions!
So what Brian has said is correct, the retry mechanism kicks in when your callback does not finish fast enough. You can either use a Semaphore to switch from the callback back to main thread and execute there, or use mbed-events to do so.
F.e.:
static M2MResource location_res = add_resource(&obj_list, 3336, 0, 0,
"Location_resource", M2MResourceInstance::STRING,M2MBase::GET_POST_ALLOWED,
"", false,
queue.event(&get_location)); // <-- this is eventqueue magic
Will execute get_location on the event loop rather than blocking the POST. This should resolve any issues you see.