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@27:38205cebc3da, 2016-09-08 (annotated)
- Committer:
- davidjhoward
- Date:
- Thu Sep 08 18:39:29 2016 +0000
- Revision:
- 27:38205cebc3da
- Parent:
- 26:6bd4868171c7
- Child:
- 68:dbe39d83eb98
more cloud data handler stuff
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 20:653923c2f37a | 1 | #include "CloudDataHandler.h" |
davidjhoward | 27:38205cebc3da | 2 | #include "CloudFileReceiver.h" |
davidjhoward | 26:6bd4868171c7 | 3 | #include "MTSLog.h" |
jmarkel44 | 20:653923c2f37a | 4 | #include <stdio.h> |
davidjhoward | 26:6bd4868171c7 | 5 | #include "mDot.h" |
davidjhoward | 26:6bd4868171c7 | 6 | #include <vector> |
jmarkel44 | 20:653923c2f37a | 7 | #include "rtos.h" |
davidjhoward | 26:6bd4868171c7 | 8 | #include "global.h" |
jmarkel44 | 20:653923c2f37a | 9 | |
jmarkel44 | 20:653923c2f37a | 10 | void CloudDataHandler(void const *args) |
jmarkel44 | 20:653923c2f37a | 11 | { |
davidjhoward | 26:6bd4868171c7 | 12 | int32_t ret; |
davidjhoward | 26:6bd4868171c7 | 13 | |
jmarkel44 | 20:653923c2f37a | 14 | printf("\r%s has started...\n", __func__); |
davidjhoward | 26:6bd4868171c7 | 15 | |
jmarkel44 | 20:653923c2f37a | 16 | while ( true ) { |
davidjhoward | 26:6bd4868171c7 | 17 | |
davidjhoward | 26:6bd4868171c7 | 18 | std::string tmp_buffer("{\"mtype\":\"20\"}"); |
davidjhoward | 26:6bd4868171c7 | 19 | std::vector<uint8_t> data(tmp_buffer.begin(), tmp_buffer.end()); |
davidjhoward | 26:6bd4868171c7 | 20 | |
davidjhoward | 26:6bd4868171c7 | 21 | // send the data to the gateway |
davidjhoward | 27:38205cebc3da | 22 | if ((ret = GLOBAL_mdot->send(data)) != mDot::MDOT_OK) { |
davidjhoward | 26:6bd4868171c7 | 23 | logError("failed to send", ret, mDot::getReturnCodeString(ret).c_str()); |
davidjhoward | 27:38205cebc3da | 24 | } else { |
davidjhoward | 26:6bd4868171c7 | 25 | logInfo("Sent to gateway: %s", tmp_buffer.c_str()); |
davidjhoward | 26:6bd4868171c7 | 26 | std::vector<uint8_t> rcvData(256); |
davidjhoward | 26:6bd4868171c7 | 27 | rcvData.clear(); |
davidjhoward | 26:6bd4868171c7 | 28 | if ((ret = GLOBAL_mdot->recv(rcvData)) == mDot::MDOT_OK) { |
davidjhoward | 26:6bd4868171c7 | 29 | if (!rcvData.empty()) { |
davidjhoward | 27:38205cebc3da | 30 | std::string rcv_string(rcvData.begin(), rcvData.end()); |
davidjhoward | 26:6bd4868171c7 | 31 | logInfo("Received Data: %s", rcv_string.c_str()); |
davidjhoward | 27:38205cebc3da | 32 | CloudFileReceiver( &rcv_string, GLOBAL_mdot ); |
davidjhoward | 26:6bd4868171c7 | 33 | } |
davidjhoward | 26:6bd4868171c7 | 34 | } |
davidjhoward | 27:38205cebc3da | 35 | Thread::wait(5000); |
davidjhoward | 26:6bd4868171c7 | 36 | } |
jmarkel44 | 20:653923c2f37a | 37 | } |
jmarkel44 | 20:653923c2f37a | 38 | } |