Commit 954a88dbb5fae3986c53b50f6ebb64d279afcc14
1 parent
66331c07
--no commit message
Showing
1 changed file
with
20 additions
and
10 deletions
Project/applications/smartcities/configServer.c
@@ -168,6 +168,18 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | @@ -168,6 +168,18 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
168 | char* value; | 168 | char* value; |
169 | uint16_t profile_enabled; | 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 | CONFIG_SERVER_DBG("Quering configuration server for variable '%s'", varName); | 183 | CONFIG_SERVER_DBG("Quering configuration server for variable '%s'", varName); |
172 | 184 | ||
173 | libwismart_ProfileGet_Int("profile_enabled", &profile_enabled); | 185 | libwismart_ProfileGet_Int("profile_enabled", &profile_enabled); |
@@ -181,7 +193,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | @@ -181,7 +193,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
181 | return WISMART_SERVER_ERR_MEM; | 193 | return WISMART_SERVER_ERR_MEM; |
182 | } | 194 | } |
183 | 195 | ||
184 | - libwismart_ProfileGet_Int("security", &security); | 196 | + security = config.security; |
185 | if(security == PROFILE_SECURITY_OPEN) | 197 | if(security == PROFILE_SECURITY_OPEN) |
186 | { | 198 | { |
187 | strcpy(value,"Open"); | 199 | strcpy(value,"Open"); |
@@ -213,7 +225,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | @@ -213,7 +225,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
213 | return WISMART_SERVER_ERR_MEM; | 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 | * Instruct server to automatically free the memory by calling the | 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,7 +246,7 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
234 | } | 246 | } |
235 | 247 | ||
236 | if(profile_enabled == PROFILE_ENABLED) { | 248 | if(profile_enabled == PROFILE_ENABLED) { |
237 | - libwismart_ProfileGet_Str("passphrase", (char*)value); | 249 | + strcpy(value,config.passphrase); |
238 | }else{ | 250 | }else{ |
239 | strcpy((char*)value, "N/A"); | 251 | strcpy((char*)value, "N/A"); |
240 | } | 252 | } |
@@ -265,8 +277,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | @@ -265,8 +277,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
265 | return WISMART_SERVER_ERR_MEM; | 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 | * Instruct server to automatically free the memory by calling the | 283 | * Instruct server to automatically free the memory by calling the |
272 | * appropriate free() function when the request is replied. | 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,8 +296,8 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
284 | return WISMART_SERVER_ERR_MEM; | 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 | * Instruct server to automatically free the memory by calling the | 302 | * Instruct server to automatically free the memory by calling the |
291 | * appropriate free() function when the request is replied. | 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,13 +311,11 @@ uint32_t configServer_dynamicCb(char* varName, char** varValue, uint8_t* varAllo | ||
299 | if(strcmp((char*)varName,"WIFI_GEOLOC") == 0){ | 311 | if(strcmp((char*)varName,"WIFI_GEOLOC") == 0){ |
300 | /* Alocate space for the value */ | 312 | /* Alocate space for the value */ |
301 | value = chHeapAlloc(NULL, 100); | 313 | value = chHeapAlloc(NULL, 100); |
302 | - char geoloc[32]; | ||
303 | if(value == NULL){ | 314 | if(value == NULL){ |
304 | return WISMART_SERVER_ERR_MEM; | 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 | * Instruct server to automatically free the memory by calling the | 321 | * Instruct server to automatically free the memory by calling the |