device manager is complete
This commit is contained in:
@@ -126,26 +126,32 @@ int DevicesManager::save(void)
|
|||||||
*/
|
*/
|
||||||
std::string DevicesManager::get(const std::string &a_capability)
|
std::string DevicesManager::get(const std::string &a_capability)
|
||||||
{
|
{
|
||||||
#if 0
|
std::string the_output;
|
||||||
Json::StyledWriter theWriter;
|
struct json_object *the_output_node;
|
||||||
Json::Value theOutput;
|
fprintf(stderr, "Devices::get...\n");
|
||||||
fprintf (stderr, "Devices::get...\n");
|
|
||||||
|
|
||||||
if (aCapability == "Lights") {
|
|
||||||
|
|
||||||
theOutput[aCapability] = mLights.to_json (true);
|
the_output_node = json_object_new_object();
|
||||||
|
|
||||||
|
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();
|
the_output = json_object_to_json_string(the_output_node);
|
||||||
#endif
|
|
||||||
|
json_object_put(the_output_node);
|
||||||
|
|
||||||
|
return the_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -163,17 +163,17 @@ int Light::send_state(void)
|
|||||||
{
|
{
|
||||||
int the_result;
|
int the_result;
|
||||||
std::string the_output_result;
|
std::string the_output_result;
|
||||||
struct json_object *the_parameter_doc;
|
struct json_object *the_parameter_node;
|
||||||
UBusCall the_cmd;
|
UBusCall the_cmd;
|
||||||
|
|
||||||
the_parameter_doc = json_object_new_object();
|
the_parameter_node = 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_node, 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_node, 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));
|
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;
|
return the_result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user