device manager is complete

This commit is contained in:
2018-04-04 23:17:25 +02:00
parent 84b00beeb2
commit 9df77ec9e3
2 changed files with 26 additions and 20 deletions

View File

@@ -126,26 +126,32 @@ int DevicesManager::save(void)
*/
std::string DevicesManager::get(const std::string &a_capability)
{
#if 0
Json::StyledWriter theWriter;
Json::Value theOutput;
std::string the_output;
struct json_object *the_output_node;
fprintf(stderr, "Devices::get...\n");
if (aCapability == "Lights") {
the_output_node = json_object_new_object();
theOutput[aCapability] = mLights.to_json (true);
if (a_capability == kLightEntry)
{
json_object_object_add(the_output_node, kLightEntry, m_lights.to_json());
}
else if (aCapability == "Shutters") {
else if (a_capability == kShutterEntry)
{
theOutput[aCapability] = mShutters.to_json (true);
json_object_object_add(the_output_node, kShutterEntry, m_shutters.to_json());
}
else if (aCapability == "Sprinklers") {
else if (a_capability == kSprinklerEntry)
{
theOutput[aCapability] = mSprinklers.to_json (true);
json_object_object_add(the_output_node, kSprinklerEntry, m_sprinklers.to_json());
}
return theWriter.write (theOutput).c_str();
#endif
the_output = json_object_to_json_string(the_output_node);
json_object_put(the_output_node);
return the_output;
}
/*! ----------------------------------------------------------------------------

View File

@@ -163,17 +163,17 @@ int Light::send_state(void)
{
int the_result;
std::string the_output_result;
struct json_object *the_parameter_doc;
struct json_object *the_parameter_node;
UBusCall the_cmd;
the_parameter_doc = json_object_new_object();
json_object_object_add(the_parameter_doc, k_entry_state, json_object_new_boolean(m_state));
json_object_object_add(the_parameter_doc, k_entry_sender, json_object_new_int(m_sender));
json_object_object_add(the_parameter_doc, k_entry_interruptor, json_object_new_int(m_interruptor));
the_parameter_node = json_object_new_object();
json_object_object_add(the_parameter_node, k_entry_state, json_object_new_boolean(m_state));
json_object_object_add(the_parameter_node, k_entry_sender, json_object_new_int(m_sender));
json_object_object_add(the_parameter_node, k_entry_interruptor, json_object_new_int(m_interruptor));
the_result = the_cmd.exec("chacon", "set", json_object_to_json_string(the_parameter_doc), the_output_result);
the_result = the_cmd.exec("chacon", "set", json_object_to_json_string(the_parameter_node), the_output_result);
json_object_put(the_parameter_doc);
json_object_put(the_parameter_node);
return the_result;
}