Commit 954a88dbb5fae3986c53b50f6ebb64d279afcc14

Authored by Imanol-Mikel Barba Sabariego
1 parent 66331c07

--no commit message

Project/applications/smartcities/configServer.c
... ... @@ -168,6 +168,18 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
168 168 char* value;
169 169 uint16_t profile_enabled;
170 170  
  171 + config_params_t config;
  172 +
  173 + if(libwismart_RegistryIsValueEmpty(&geo))
  174 + {
  175 + value = chHeapAlloc(NULL, 100);
  176 + strcpy(value,"N/A");
  177 + *varAllocType = WISMART_SERVER_ALLOC_DYNAMIC;
  178 + (*varValue) = value;
  179 + return WISMART_SERVER_ERR_OK;
  180 + }
  181 + libwismart_RegistryGet(&geo,&config);
  182 +
171 183 CONFIG_SERVER_DBG("Quering configuration server for variable '%s'", varName);
172 184  
173 185 libwismart_ProfileGet_Int("profile_enabled", &profile_enabled);
... ... @@ -181,7 +193,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
181 193 return WISMART_SERVER_ERR_MEM;
182 194 }
183 195  
184   - libwismart_ProfileGet_Int("security", &security);
  196 + security = config.security;
185 197 if(security == PROFILE_SECURITY_OPEN)
186 198 {
187 199 strcpy(value,"Open");
... ... @@ -213,7 +225,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
213 225 return WISMART_SERVER_ERR_MEM;
214 226 }
215 227  
216   - libwismart_ProfileGet_Str("ssid", (char*)value);
  228 + strcpy(value,config.ssid);
217 229  
218 230 /*
219 231 * 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
234 246 }
235 247  
236 248 if(profile_enabled == PROFILE_ENABLED) {
237   - libwismart_ProfileGet_Str("passphrase", (char*)value);
  249 + strcpy(value,config.passphrase);
238 250 }else{
239 251 strcpy((char*)value, "N/A");
240 252 }
... ... @@ -265,8 +277,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
265 277 return WISMART_SERVER_ERR_MEM;
266 278 }
267 279  
268   - libwismart_ProfileGet_Str("gateway", (char*)value);
269   -
  280 + strcpy(value,config.user);
  281 +
270 282 /*
271 283 * Instruct server to automatically free the memory by calling the
272 284 * appropriate free() function when the request is replied.
... ... @@ -284,8 +296,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
284 296 return WISMART_SERVER_ERR_MEM;
285 297 }
286 298  
287   - libwismart_ProfileGet_Str("netmask", (char*)value);
288   -
  299 + strcpy(value,config.password);
  300 +
289 301 /*
290 302 * Instruct server to automatically free the memory by calling the
291 303 * appropriate free() function when the request is replied.
... ... @@ -299,13 +311,11 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo
299 311 if(strcmp((char*)varName,"WIFI_GEOLOC") == 0){
300 312 /* Alocate space for the value */
301 313 value = chHeapAlloc(NULL, 100);
302   - char geoloc[32];
303 314 if(value == NULL){
304 315 return WISMART_SERVER_ERR_MEM;
305 316 }
306 317  
307   - libwismart_RegistryGet(&geo,&geoloc);
308   - strcpy(value,geoloc);
  318 + strcpy(value, config.localization);
309 319  
310 320 /*
311 321 * Instruct server to automatically free the memory by calling the
... ...