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
Diff: src/CloudDataHandler/CloudFileReceiver.cpp
- Revision:
- 99:55317f374a94
- Parent:
- 49:0456ee2271be
- Child:
- 116:7337ed514891
--- a/src/CloudDataHandler/CloudFileReceiver.cpp Tue Sep 20 19:58:36 2016 +0000
+++ b/src/CloudDataHandler/CloudFileReceiver.cpp Wed Sep 21 20:32:19 2016 +0000
@@ -8,80 +8,80 @@
bool StoreReceivedFile( mDot *dot, MbedJSONValue &from_json )
{
- FILENAME_STRING filename;
+ FILENAME_STRING filename;
- memset( filename, '\0', sizeof(FILENAME_STRING) );
+ memset( filename, '\0', sizeof(FILENAME_STRING) );
- int mType = from_json["pay"]["mtype"].get<int>();
- logInfo("mtype=%d", mType);
- switch( mType ) {
- case SETPOINT_CONTROL_MTYPE: {
- logInfo("PROCESSING SETPONT CONTROL FILE");
- snprintf( filename, sizeof(FILENAME_STRING), "%s_%s%s",
- from_json["pay"]["spcontrol"]["id"].get<std::string>().c_str(),
- from_json["pay"]["spcontrol"]["input"].get<std::string>().c_str(),
- ".json" );
- logInfo("SETPONT CONTROL FILENAME=%s", filename);
- break;
- }
- case TIMER_CONTROL_MTYPE:
- break;
- case INPUT_CONFIG_MTYPE: {
- logInfo("id=%s", from_json["pay"]["input"]["id"].get<std::string>().c_str() );
- snprintf( filename, sizeof(FILENAME_STRING), "input_%s%s",
- from_json["pay"]["input"]["id"].get<std::string>().c_str(),
- ".jsn" );
- logInfo("INPUT CONFIG FILENAME=%s", filename);
+ int mType = from_json["pay"]["mtype"].get<int>();
+ logInfo("mtype=%d", mType);
+ switch( mType ) {
+ case SETPOINT_CONTROL_MTYPE: {
+ logInfo("PROCESSING SETPONT CONTROL FILE");
+ snprintf( filename, sizeof(FILENAME_STRING), "%s_%s%s",
+ from_json["pay"]["spcontrol"]["id"].get<std::string>().c_str(),
+ from_json["pay"]["spcontrol"]["input"].get<std::string>().c_str(),
+ ".json" );
+ logInfo("SETPONT CONTROL FILENAME=%s", filename);
+ break;
+ }
+ case TIMER_CONTROL_MTYPE:
+ break;
+ case INPUT_CONFIG_MTYPE: {
+ logInfo("id=%s", from_json["pay"]["input"]["id"].get<std::string>().c_str() );
+ snprintf( filename, sizeof(FILENAME_STRING), "input_%s%s",
+ from_json["pay"]["input"]["id"].get<std::string>().c_str(),
+ ".jsn" );
+ logInfo("INPUT CONFIG FILENAME=%s", filename);
- memset( CloudFileReceiverWriteBuf, '\0', 1024 );
- snprintf(CloudFileReceiverWriteBuf, sizeof(CloudFileReceiverWriteBuf),
- "{ "
- "\"id\":\"%s\", "
- "\"name\":\"%s\", "
- "\"units\":\"%s\", "
- "\"min\":\"%s\", "
- "\"max\":\"%s\", "
- "\"node\":\"%s\", "
- "\"reg\":\"%s\", "
- "\"rtype\":\"%s\", "
- "\"type\":\"%s\", "
- "\"size\":\"%s\", "
- "\"order\":\"%s\", "
- "\"fmt\":\"%s\", "
- "\"rfreq\":\"%s\" } ",
- from_json["pay"]["input"]["id"].get<std::string>().c_str(),
- from_json["pay"]["input"]["name"].get<std::string>().c_str(),
- from_json["pay"]["input"]["units"].get<std::string>().c_str(),
- from_json["pay"]["input"]["min"].get<std::string>().c_str(),
- from_json["pay"]["input"]["max"].get<std::string>().c_str(),
- from_json["pay"]["input"]["node"].get<std::string>().c_str(),
- from_json["pay"]["input"]["reg"].get<std::string>().c_str(),
- from_json["pay"]["input"]["rtype"].get<std::string>().c_str(),
- from_json["pay"]["input"]["type"].get<std::string>().c_str(),
- from_json["pay"]["input"]["size"].get<std::string>().c_str(),
- from_json["pay"]["input"]["order"].get<std::string>().c_str(),
- from_json["pay"]["input"]["fmt"].get<std::string>().c_str(),
- from_json["pay"]["input"]["rfreq"].get<std::string>().c_str()
- );
+ memset( CloudFileReceiverWriteBuf, '\0', 1024 );
+ snprintf(CloudFileReceiverWriteBuf, sizeof(CloudFileReceiverWriteBuf),
+ "{ "
+ "\"id\":\"%s\", "
+ "\"name\":\"%s\", "
+ "\"units\":\"%s\", "
+ "\"min\":\"%s\", "
+ "\"max\":\"%s\", "
+ "\"node\":\"%s\", "
+ "\"reg\":\"%s\", "
+ "\"rtype\":\"%s\", "
+ "\"type\":\"%s\", "
+ "\"size\":\"%s\", "
+ "\"order\":\"%s\", "
+ "\"fmt\":\"%s\", "
+ "\"rfreq\":\"%s\" } ",
+ from_json["pay"]["input"]["id"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["name"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["units"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["min"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["max"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["node"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["reg"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["rtype"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["type"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["size"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["order"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["fmt"].get<std::string>().c_str(),
+ from_json["pay"]["input"]["rfreq"].get<std::string>().c_str()
+ );
- logInfo("saving string%s", CloudFileReceiverWriteBuf);
- bool status = GLOBAL_mdot->saveUserFile(filename, (void *)CloudFileReceiverWriteBuf, 1024);
- if( status != true ) {
- logError("(%d)save file failed, status=%d", __LINE__, status);
- }
+ logInfo("saving string%s", CloudFileReceiverWriteBuf);
+ bool status = GLOBAL_mdot->saveUserFile(filename, (void *)CloudFileReceiverWriteBuf, 1024);
+ if( status != true ) {
+ logError("(%d)save file failed, status=%d", __LINE__, status);
+ }
- logInfo("Sending Mail To ModbusMasterMailBox, filename=%s", filename);
- Message_t *mail = ModbusMasterMailBox.alloc();
- mail->action = ACTION_READ_FILE;
- strncpy( mail->controlFile, filename, (sizeof(mail->controlFile)-1));
- ModbusMasterMailBox.put(mail);
- break;
- }
- default:
- logInfo("DEFAULT");
- break;
+ logInfo("Sending Mail To ModbusMasterMailBox, filename=%s", filename);
+ Message_t *mail = ModbusMasterMailBox.alloc();
+ mail->action = ACTION_READ_FILE;
+ strncpy( mail->controlFile, filename, (sizeof(mail->controlFile)-1));
+ ModbusMasterMailBox.put(mail);
+ break;
}
- return true;
+ default:
+ logInfo("DEFAULT");
+ break;
+ }
+ return true;
}
bool CloudFileReceiver( std::string *recv_string, mDot *dot )
@@ -127,6 +127,12 @@
parse( final_json, CloudFileReceiverWriteBuf );
+ int sequence = final_json["seq"].get<int>();
+ int mType = final_json["pay"]["mtype"].get<int>();
+ std::string input = final_json["pay"]["input"]["id"].get<std::string>().c_str();
+
+ printf("MESSAGE TYPE=%d, input=%s\r\n",mType, input.c_str());
+
status = StoreReceivedFile( dot, final_json );
if( status != true ) {
logError("(%d)save file failed, status=%d", __LINE__, status);
