Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/CloudDataHandler/CloudDataHandler.cpp
- Committer:
- davidjhoward
- Date:
- 2016-09-30
- Revision:
- 149:950c90425f7c
- Parent:
- 123:ce602c91a9c3
- Child:
- 284:cc72206ea8e0
File content as of revision 149:950c90425f7c:
#include "CloudDataHandler.h" #include "CloudFileReceiver.h" #include "LogHandler.h" #include "MTSLog.h" #include <stdio.h> #include "mDot.h" #include <vector> #include "rtos.h" #include "global.h" void CloudDataHandler(void const *args) { int32_t ret; bool joined; bool sent; printf("\r%s has started...\n", __func__); while ( true ) { std::string tmp_buffer; if (!GLOBAL_mdot->getNetworkJoinStatus()) { logInfo("network not joined, joining network"); if ((ret = GLOBAL_mdot->joinNetwork()) != mDot::MDOT_OK) { logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); joined = false; } } else { joined = true; } sent = LogHandler( joined ); if( sent == true ) { // sent a packet, try to receive back. logInfo("Sent to gateway: %s", tmp_buffer.c_str()); std::vector<uint8_t> rcvData(256); rcvData.clear(); if ((ret = GLOBAL_mdot->recv(rcvData)) == mDot::MDOT_OK) { if (!rcvData.empty()) { std::string rcv_string(rcvData.begin(), rcvData.end()); logInfo("Received Data: %s", rcv_string.c_str()); CloudFileReceiver( &rcv_string, GLOBAL_mdot ); } } } Thread::wait(1000); } }