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.
ICE-Application/src/CloudDataHandler/CloudDataHandler.cpp@0:61364762ee0e, 2017-01-24 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Jan 24 19:05:33 2017 +0000
- Revision:
- 0:61364762ee0e
Port from IAR to Nucleo-F412 board
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:61364762ee0e | 1 | /****************************************************************************** |
jmarkel44 | 0:61364762ee0e | 2 | * |
jmarkel44 | 0:61364762ee0e | 3 | * File: CloudDataHandler.cpp |
jmarkel44 | 0:61364762ee0e | 4 | * Description: |
jmarkel44 | 0:61364762ee0e | 5 | * |
jmarkel44 | 0:61364762ee0e | 6 | *****************************************************************************/ |
jmarkel44 | 0:61364762ee0e | 7 | #include "CloudDataHandler.h" |
jmarkel44 | 0:61364762ee0e | 8 | #include "CloudFileReceiver.h" |
jmarkel44 | 0:61364762ee0e | 9 | #include "LogHandler.h" |
jmarkel44 | 0:61364762ee0e | 10 | #include <stdio.h> |
jmarkel44 | 0:61364762ee0e | 11 | #include <vector> |
jmarkel44 | 0:61364762ee0e | 12 | #include "rtos.h" |
jmarkel44 | 0:61364762ee0e | 13 | #include "global.h" |
jmarkel44 | 0:61364762ee0e | 14 | |
jmarkel44 | 0:61364762ee0e | 15 | // |
jmarkel44 | 0:61364762ee0e | 16 | // The Cloud Data Handler task |
jmarkel44 | 0:61364762ee0e | 17 | // |
jmarkel44 | 0:61364762ee0e | 18 | void CloudDataHandler(void const *args) |
jmarkel44 | 0:61364762ee0e | 19 | { |
jmarkel44 | 0:61364762ee0e | 20 | #if 0 |
jmarkel44 | 0:61364762ee0e | 21 | int32_t ret; |
jmarkel44 | 0:61364762ee0e | 22 | bool joined; |
jmarkel44 | 0:61364762ee0e | 23 | bool sent; |
jmarkel44 | 0:61364762ee0e | 24 | #endif |
jmarkel44 | 0:61364762ee0e | 25 | |
jmarkel44 | 0:61364762ee0e | 26 | printf("\r%s has started...\n", __func__); |
jmarkel44 | 0:61364762ee0e | 27 | |
jmarkel44 | 0:61364762ee0e | 28 | while ( true ) { |
jmarkel44 | 0:61364762ee0e | 29 | |
jmarkel44 | 0:61364762ee0e | 30 | std::string tmp_buffer; |
jmarkel44 | 0:61364762ee0e | 31 | #if 0 |
jmarkel44 | 0:61364762ee0e | 32 | if (!GLOBAL_mdot->getNetworkJoinStatus()) { |
jmarkel44 | 0:61364762ee0e | 33 | logInfo("network not joined, joining network"); |
jmarkel44 | 0:61364762ee0e | 34 | if ((ret = GLOBAL_mdot->joinNetwork()) != mDot::MDOT_OK) { |
jmarkel44 | 0:61364762ee0e | 35 | printf("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); |
jmarkel44 | 0:61364762ee0e | 36 | joined = false; |
jmarkel44 | 0:61364762ee0e | 37 | } |
jmarkel44 | 0:61364762ee0e | 38 | } else { |
jmarkel44 | 0:61364762ee0e | 39 | joined = true; |
jmarkel44 | 0:61364762ee0e | 40 | } |
jmarkel44 | 0:61364762ee0e | 41 | |
jmarkel44 | 0:61364762ee0e | 42 | sent = LogHandler( joined ); |
jmarkel44 | 0:61364762ee0e | 43 | if( sent == true ) { |
jmarkel44 | 0:61364762ee0e | 44 | // sent a packet, try to receive back. |
jmarkel44 | 0:61364762ee0e | 45 | printf("Sent to gateway: %s", tmp_buffer.c_str()); |
jmarkel44 | 0:61364762ee0e | 46 | std::vector<uint8_t> rcvData(256); |
jmarkel44 | 0:61364762ee0e | 47 | rcvData.clear(); |
jmarkel44 | 0:61364762ee0e | 48 | if ((ret = GLOBAL_mdot->recv(rcvData)) == mDot::MDOT_OK) { |
jmarkel44 | 0:61364762ee0e | 49 | if (!rcvData.empty()) { |
jmarkel44 | 0:61364762ee0e | 50 | std::string rcv_string(rcvData.begin(), rcvData.end()); |
jmarkel44 | 0:61364762ee0e | 51 | printf("Received Data: %s", rcv_string.c_str()); |
jmarkel44 | 0:61364762ee0e | 52 | CloudFileReceiver( &rcv_string, GLOBAL_mdot ); |
jmarkel44 | 0:61364762ee0e | 53 | } |
jmarkel44 | 0:61364762ee0e | 54 | } |
jmarkel44 | 0:61364762ee0e | 55 | } |
jmarkel44 | 0:61364762ee0e | 56 | #endif |
jmarkel44 | 0:61364762ee0e | 57 | Thread::wait(1000); |
jmarkel44 | 0:61364762ee0e | 58 | } |
jmarkel44 | 0:61364762ee0e | 59 | } |