Commit f1415b99 authored by Michael Tross's avatar Michael Tross

support zoneID property

parent 11dac796
......@@ -104,6 +104,8 @@ read_config()
sprintf(path, "module.m%d.id", n);
if (config_lookup_string(&config, path, (const char **) &sval))
module->id = strdup(sval);
sprintf(path, "module.m%d.zoneid", n);
config_lookup_int(&config, path, (int *) &module->zoneID);
sprintf(path, "module.m%d.last_message", n);
config_lookup_int(&config, path, (int *) &module->last_message);
sprintf(path, "module.m%d.last_seen", n);
......@@ -305,6 +307,12 @@ write_config()
}
config_setting_set_string(setting, module->id);
setting = config_setting_add(s, "zoneid", CONFIG_TYPE_INT);
if (setting == NULL) {
setting = config_setting_get_member(s, "zoneid");
}
config_setting_set_int(setting, module->zoneID);
setting = config_setting_add(s, "last_message", CONFIG_TYPE_INT);
if (setting == NULL) {
setting = config_setting_get_member(s, "last_message");
......
......@@ -55,6 +55,7 @@ typedef struct netatmo_module
int battery_percent;
unsigned char bid_length;
unsigned char bid[16];
uint16_t zoneID;
} netatmo_module_t;
typedef struct netatmo_base
......
......@@ -663,6 +663,7 @@ int netatmo_get_devices()
dev->id = strdup(buffer);
dev->mod = m;
dev->present = true;
m->zoneID = 65534;
dsuid_generate_v3_from_namespace(DSUID_NS_IEEE_MAC, buffer, &dev->dsuid);
dsuid_to_string(&dev->dsuid, dev->dsuidstring);
......
......@@ -302,6 +302,62 @@ void vdc_setprop_cb(dsvdc_t *handle, const char *dsuid, dsvdc_property_t *proper
if (code == DSVDC_OK) {
write_config();
}
dsvdc_send_set_property_response(handle, property, code);
return;
}
netatmo_vdcd_t* dev;
pthread_mutex_lock(&g_network_mutex);
LL_FOREACH(devlist, dev)
{
if (strcasecmp(dsuid, dev->dsuidstring) == 0) {
break;
}
}
pthread_mutex_unlock(&g_network_mutex);
if (dev == NULL) {
vdc_report(LOG_WARNING, "set property: unhandled dsuid %s\n", dsuid);
dsvdc_property_free(property);
return;
}
/*
* Properties for the VDSD's
*/
pthread_mutex_lock(&g_network_mutex);
for (i = 0; i < dsvdc_property_get_num_properties(properties); i++) {
char *name;
int ret = dsvdc_property_get_name(properties, i, &name);
if (ret != DSVDC_OK) {
vdc_report(LOG_ERR, "getprop_cb: error getting property name, abort\n");
dsvdc_send_get_property_response(handle, property);
pthread_mutex_unlock(&g_network_mutex);
return;
}
if (!name) {
vdc_report(LOG_ERR, "getprop_cb: not yet handling wildcard properties\n");
//dsvdc_send_property_response(handle, property);
continue;
}
vdc_report(LOG_NOTICE, "get request name=\"%s\"\n", name);
if (strcmp(name, "zoneID") == 0) {
uint64_t zoneID;
ret = dsvdc_property_get_uint(properties, i, &zoneID);
if (ret != DSVDC_OK) {
vdc_report(LOG_ERR, "setprop_cb: error getting property value from property %s\n", name);
code = DSVDC_ERR_INVALID_VALUE_TYPE;
break;
}
vdc_report(LOG_NOTICE, "setprop_cb: \"%s\" = %d\n", name, zoneID);
dev->mod->zoneID = zoneID;
code = DSVDC_OK;
}
free(name);
}
dsvdc_send_set_property_response(handle, property, code);
......@@ -444,6 +500,9 @@ void vdc_getprop_cb(dsvdc_t *handle, const char *dsuid, dsvdc_property_t *proper
if (strcmp(name, "primaryGroup") == 0) {
dsvdc_property_add_uint(property, "primaryGroup", 8);
} else if (strcmp(name, "zoneID") == 0) {
dsvdc_property_add_uint(property, "zoneID", dev->mod->zoneID);
} else if (strcmp(name, "buttonInputDescriptions") == 0) {
} else if (strcmp(name, "buttonInputSettings") == 0) {
} else if (strcmp(name, "outputDescription") == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment