Commit 5e443631 authored by Christian Hitz's avatar Christian Hitz

Merge branch 'master' into testing

parents ebd6c884 5f29d20f
......@@ -76,6 +76,8 @@ read_config()
g_resync_devices = ivalue;
if (config_lookup_int(&config, "reload_values", (int *) &ivalue))
g_reload_values = ivalue;
if (config_lookup_int(&config, "zone_id", (int *) &ivalue))
g_default_zoneID = ivalue;
if (config_lookup_int(&config, "debug", (int *) &ivalue)) {
if (ivalue <= 10) {
vdc_set_debugLevel(ivalue);
......@@ -239,6 +241,12 @@ write_config()
}
config_setting_set_int(setting, g_reload_values);
setting = config_setting_add(cfg_root, "zone_id", CONFIG_TYPE_INT);
if (setting == NULL) {
setting = config_setting_get_member(cfg_root, "zone_id");
}
config_setting_set_int(setting, g_default_zoneID);
setting = config_setting_add(cfg_root, "debug", CONFIG_TYPE_INT);
if (setting == NULL) {
setting = config_setting_get_member(cfg_root, "debug");
......
......@@ -64,6 +64,7 @@ char *g_access_token = NULL;
time_t g_access_token_valid_until = 0;
time_t g_resync_devices = 60 * 60;
time_t g_reload_values = 5 * 60;
int g_default_zoneID = 65534;
static time_t g_query_devices_time = 0;
static time_t g_query_values_time = 0;
......@@ -311,9 +312,9 @@ int main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
}
if (!dev->present) {
if (!dev->presentSignaled) {
if (dev->presentSignaled) {
dsvdc_device_vanished(handle, dev->dsuidstring);
dev->presentSignaled = true;
dev->presentSignaled = false;
continue;
}
} else {
......@@ -325,7 +326,7 @@ int main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
}
// Test first element if there are new values
if (dev->mod->values[0].last_reported >= dev->mod->values[0].last_query) {
if (dev->announced && (dev->mod->values[0].last_reported >= dev->mod->values[0].last_query)) {
continue;
}
......
......@@ -120,6 +120,7 @@ extern char *g_access_token;
extern time_t g_access_token_valid_until;
extern time_t g_resync_devices;
extern time_t g_reload_values;
extern int g_default_zoneID;
extern void vdc_new_session_cb(dsvdc_t *handle __attribute__((unused)), void *userdata);
extern void vdc_ping_cb(dsvdc_t *handle __attribute__((unused)), const char *dsuid, void *userdata __attribute__((unused)));
......
......@@ -291,6 +291,19 @@ void vdc_setprop_cb(dsvdc_t *handle, const char *dsuid, dsvdc_property_t *proper
code = DSVDC_OK;
}
else 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);
g_default_zoneID = zoneID;
code = DSVDC_OK;
}
else {
code = DSVDC_ERR_NOT_FOUND;
break;
......@@ -359,6 +372,7 @@ void vdc_setprop_cb(dsvdc_t *handle, const char *dsuid, dsvdc_property_t *proper
free(name);
}
pthread_mutex_unlock(&g_network_mutex);
dsvdc_send_set_property_response(handle, property, code);
}
......@@ -447,6 +461,9 @@ void vdc_getprop_cb(dsvdc_t *handle, const char *dsuid, dsvdc_property_t *proper
} else if (strcmp(name, "configURL") == 0) {
dsvdc_property_add_string(property, name, "/add-ons/vdc-ui-netatmo/");
} else if (strcmp(name, "zoneID") == 0) {
dsvdc_property_add_uint(property, "zoneID", g_default_zoneID);
/* user properties: user name, client_id, status */
} else if (strcmp(name, "x-netatmo-username") == 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