From 954a88dbb5fae3986c53b50f6ebb64d279afcc14 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Thu, 15 May 2014 14:50:04 +0000 Subject: [PATCH] --- Project/applications/smartcities/configServer.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Project/applications/smartcities/configServer.c b/Project/applications/smartcities/configServer.c index be3c91a..0052d62 100644 --- a/Project/applications/smartcities/configServer.c +++ b/Project/applications/smartcities/configServer.c @@ -168,6 +168,18 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo char* value; uint16_t profile_enabled; + config_params_t config; + + if(libwismart_RegistryIsValueEmpty(&geo)) + { + value = chHeapAlloc(NULL, 100); + strcpy(value,"N/A"); + *varAllocType = WISMART_SERVER_ALLOC_DYNAMIC; + (*varValue) = value; + return WISMART_SERVER_ERR_OK; + } + libwismart_RegistryGet(&geo,&config); + CONFIG_SERVER_DBG("Quering configuration server for variable '%s'", varName); libwismart_ProfileGet_Int("profile_enabled", &profile_enabled); @@ -181,7 +193,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo return WISMART_SERVER_ERR_MEM; } - libwismart_ProfileGet_Int("security", &security); + security = config.security; if(security == PROFILE_SECURITY_OPEN) { strcpy(value,"Open"); @@ -213,7 +225,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo return WISMART_SERVER_ERR_MEM; } - libwismart_ProfileGet_Str("ssid", (char*)value); + strcpy(value,config.ssid); /* * Instruct server to automatically free the memory by calling the @@ -234,7 +246,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo } if(profile_enabled == PROFILE_ENABLED) { - libwismart_ProfileGet_Str("passphrase", (char*)value); + strcpy(value,config.passphrase); }else{ strcpy((char*)value, "N/A"); } @@ -265,8 +277,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo return WISMART_SERVER_ERR_MEM; } - libwismart_ProfileGet_Str("gateway", (char*)value); - + strcpy(value,config.user); + /* * Instruct server to automatically free the memory by calling the * appropriate free() function when the request is replied. @@ -284,8 +296,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo return WISMART_SERVER_ERR_MEM; } - libwismart_ProfileGet_Str("netmask", (char*)value); - + strcpy(value,config.password); + /* * Instruct server to automatically free the memory by calling the * appropriate free() function when the request is replied. @@ -299,13 +311,11 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo if(strcmp((char*)varName,"WIFI_GEOLOC") == 0){ /* Alocate space for the value */ value = chHeapAlloc(NULL, 100); - char geoloc[32]; if(value == NULL){ return WISMART_SERVER_ERR_MEM; } - libwismart_RegistryGet(&geo,&geoloc); - strcpy(value,geoloc); + strcpy(value, config.localization); /* * Instruct server to automatically free the memory by calling the -- libgit2 0.22.2