BigW Consortium Gitlab

Commit 728f3703 by David Frey

locationService: cleanup indentation

parent 010db486
...@@ -124,7 +124,7 @@ static void PackJson ...@@ -124,7 +124,7 @@ static void PackJson
res = le_pos_GetTime(&hours, &minutes, &seconds, &millis); res = le_pos_GetTime(&hours, &minutes, &seconds, &millis);
if (res == LE_OK){ if (res == LE_OK){
res = le_pos_GetDate(&years, &months, &days); res = le_pos_GetDate(&years, &months, &days);
if (res == LE_OK){ if (res == LE_OK){
time ( &rawtime ); time ( &rawtime );
timeinfo = localtime ( &rawtime ); timeinfo = localtime ( &rawtime );
timeinfo->tm_year = years - 1900; timeinfo->tm_year = years - 1900;
...@@ -146,18 +146,18 @@ static void PackJson ...@@ -146,18 +146,18 @@ static void PackJson
} }
if (loc == GPS) if (loc == GPS)
len = snprintf(jsonp, jsonl, len = snprintf(jsonp, jsonl,
"{ \"lat\": %lf, \"lon\": %lf, \"hAcc\": %lf," "{ \"lat\": %lf, \"lon\": %lf, \"hAcc\": %lf,"
" \"alt\": %lf, \"vAcc\": %lf, \"fixType\" : \"GNSS\", \"ts\" : %ju}", " \"alt\": %lf, \"vAcc\": %lf, \"fixType\" : \"GNSS\", \"ts\" : %ju}",
scanp->lat, scanp->lon, scanp->hAccuracy, scanp->lat, scanp->lon, scanp->hAccuracy,
scanp->alt, scanp->vAccuracy, (uintmax_t)ts); scanp->alt, scanp->vAccuracy, (uintmax_t)ts);
else if (loc == WIFI) else if (loc == WIFI)
len = snprintf(jsonp, jsonl, len = snprintf(jsonp, jsonl,
"{ \"lat\": %lf, \"lon\": %lf, \"hAcc\": %lf," "{ \"lat\": %lf, \"lon\": %lf, \"hAcc\": %lf,"
" \"fixType\" : \"WIFI\", \"ts\" : %ju}", " \"fixType\" : \"WIFI\", \"ts\" : %ju}",
scanp->lat, scanp->lon, scanp->hAccuracy, (uintmax_t)ts); scanp->lat, scanp->lon, scanp->hAccuracy, (uintmax_t)ts);
else else
LE_FATAL("ILLEGAL Location Type: WIFI|GPS"); LE_FATAL("ILLEGAL Location Type: WIFI|GPS");
if (len >= jsonl) if (len >= jsonl)
{ {
...@@ -172,25 +172,26 @@ static void LocationResultHandler( ...@@ -172,25 +172,26 @@ static void LocationResultHandler(
{ {
case MA_COMBAINLOCATION_RESULT_SUCCESS: case MA_COMBAINLOCATION_RESULT_SUCCESS:
{ {
Scan_t scan; Scan_t scan;
char json[256]; char json[256];
const le_result_t res = ma_combainLocation_GetSuccessResponse( const le_result_t res = ma_combainLocation_GetSuccessResponse(
handle, &scan.lat, &scan.lon, &scan.hAccuracy); handle, &scan.lat, &scan.lon, &scan.hAccuracy);
if (res != LE_OK) if (res != LE_OK)
{ {
LE_INFO("Received result notification of type success response, but couldn't fetch the result\n"); LE_INFO(
"Received result notification of type success response, but couldn't fetch the result\n");
exit(1); exit(1);
} }
else else
{ {
LE_INFO("Location: latitude=%f, longitude=%f, accuracy=%f meters\n", LE_INFO("Location: latitude=%f, longitude=%f, accuracy=%f meters\n",
scan.lat, scan.lon, scan.hAccuracy); scan.lat, scan.lon, scan.hAccuracy);
PackJson(WIFI, &scan, json, sizeof(json)); PackJson(WIFI, &scan, json, sizeof(json));
LE_INFO("Sent dhub json: %s", json); LE_INFO("Sent dhub json: %s", json);
psensor_PushJson(saved_ref, 0 /* now */, json); psensor_PushJson(saved_ref, 0 /* now */, json);
saved_ref = NULL; saved_ref = NULL;
} }
break; break;
} }
...@@ -216,7 +217,8 @@ static void LocationResultHandler( ...@@ -216,7 +217,8 @@ static void LocationResultHandler(
sizeof(message) - 1); sizeof(message) - 1);
if (res != LE_OK) if (res != LE_OK)
{ {
LE_INFO("Received result notification of type success response, but couldn't fetch the result\n"); LE_INFO(
"Received result notification of type success response, but couldn't fetch the result\n");
exit(1); exit(1);
} }
else else
...@@ -240,7 +242,8 @@ static void LocationResultHandler( ...@@ -240,7 +242,8 @@ static void LocationResultHandler(
handle, rawResult, sizeof(rawResult) - 1); handle, rawResult, sizeof(rawResult) - 1);
if (res != LE_OK) if (res != LE_OK)
{ {
LE_INFO("Received result notification of type success response, but couldn't fetch the result\n"); LE_INFO(
"Received result notification of type success response, but couldn't fetch the result\n");
exit(1); exit(1);
} }
else else
...@@ -271,8 +274,8 @@ static bool TrySubmitRequest(void) ...@@ -271,8 +274,8 @@ static bool TrySubmitRequest(void)
State.combainHandle, LocationResultHandler, NULL); State.combainHandle, LocationResultHandler, NULL);
if (res != LE_OK) if (res != LE_OK)
LE_FATAL("Failed to submit location request\n"); LE_FATAL("Failed to submit location request\n");
LE_INFO("Submitted request handle: %d", (uint32_t) State.combainHandle); LE_INFO("Submitted request handle: %d", (uint32_t) State.combainHandle);
return true; return true;
} }
...@@ -330,7 +333,8 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context) ...@@ -330,7 +333,8 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context)
res = ma_combainLocation_AppendWifiAccessPoint( res = ma_combainLocation_AppendWifiAccessPoint(
State.combainHandle, bssidBytes, 6, ssid, ssidLen, signalStrength); State.combainHandle, bssidBytes, 6, ssid, ssidLen, signalStrength);
LE_INFO("Submitted AccessPoint: %d ssid: %s", (uint32_t) State.combainHandle, (char *) ssid); LE_INFO("Submitted AccessPoint: %d ssid: %s", (uint32_t) State.combainHandle,
(char *) ssid);
if (res != LE_OK) if (res != LE_OK)
{ {
...@@ -373,7 +377,7 @@ static void Sample ...@@ -373,7 +377,7 @@ static void Sample
le_result_t posRes = le_pos_Get3DLocation(&lat, &lon, &hAccuracy, &alt, &vAccuracy); le_result_t posRes = le_pos_Get3DLocation(&lat, &lon, &hAccuracy, &alt, &vAccuracy);
/* LE_INFO("le_pos_Get3DLocation returned: lat = %d lon: %d hAccuracy: %d alt: %d vAccuracy: %d", /* LE_INFO("le_pos_Get3DLocation returned: lat = %d lon: %d hAccuracy: %d alt: %d vAccuracy: %d",
lat, lon, hAccuracy, alt, vAccuracy); */ lat, lon, hAccuracy, alt, vAccuracy); */
scan.lat = (double) lat / 1000000.0 ; scan.lat = (double) lat / 1000000.0 ;
scan.lon = (double) lon / 1000000.0; scan.lon = (double) lon / 1000000.0;
...@@ -382,18 +386,18 @@ static void Sample ...@@ -382,18 +386,18 @@ static void Sample
scan.vAccuracy = (double) vAccuracy; scan.vAccuracy = (double) vAccuracy;
/* LE_INFO("CVT double: lat = %f lon: %f hAccuracy: %f alt: %f vAccuracy: %f", /* LE_INFO("CVT double: lat = %f lon: %f hAccuracy: %f alt: %f vAccuracy: %f",
scan.lat, scan.lon, scan.hAccuracy, scan.alt, scan.vAccuracy); */ scan.lat, scan.lon, scan.hAccuracy, scan.alt, scan.vAccuracy); */
// No GPS or low accuracy GPS try Wifi Scan & Combain translation // No GPS or low accuracy GPS try Wifi Scan & Combain translation
if (posRes != LE_OK || scan.hAccuracy > HACCURACY_GOOD) { if (posRes != LE_OK || scan.hAccuracy > HACCURACY_GOOD) {
le_result_t startRes; le_result_t startRes;
if (!State.waitingForWifiResults) { if (!State.waitingForWifiResults) {
/* Legato WIFI is broken so we need to create a fake access point to do a scan */ /* Legato WIFI is broken so we need to create a fake access point to do a scan */
const char *ssidPtr = "mangOH"; const char *ssidPtr = "mangOH";
le_wifiClient_AccessPointRef_t createdAccessPoint; le_wifiClient_AccessPointRef_t createdAccessPoint;
createdAccessPoint = le_wifiClient_Create((const uint8_t *)ssidPtr, strlen(ssidPtr)); createdAccessPoint = le_wifiClient_Create((const uint8_t *)ssidPtr, strlen(ssidPtr));
if (NULL == createdAccessPoint) if (NULL == createdAccessPoint)
{ {
LE_INFO("le_wifiClient_Create returns NULL.\n"); LE_INFO("le_wifiClient_Create returns NULL.\n");
...@@ -411,28 +415,28 @@ static void Sample ...@@ -411,28 +415,28 @@ static void Sample
if (startRes != LE_OK && startRes != LE_BUSY) { if (startRes != LE_OK && startRes != LE_BUSY) {
LE_FATAL("Couldn't start the WiFi service error code: %s", LE_RESULT_TXT(startRes)); LE_FATAL("Couldn't start the WiFi service error code: %s", LE_RESULT_TXT(startRes));
exit(1); exit(1);
} }
le_wifiClient_Scan(); le_wifiClient_Scan();
State.combainHandle = ma_combainLocation_CreateLocationRequest(); State.combainHandle = ma_combainLocation_CreateLocationRequest();
LE_INFO("Create request handle: %d", (uint32_t) State.combainHandle); LE_INFO("Create request handle: %d", (uint32_t) State.combainHandle);
saved_ref = ref; saved_ref = ref;
State.waitingForWifiResults = true; State.waitingForWifiResults = true;
} }
else else
LE_INFO("le_wifiClient_Scan still RUNNING"); LE_INFO("le_wifiClient_Scan still RUNNING");
} }
// Good GPS // Good GPS
else if (posRes == LE_OK && scan.hAccuracy <= HACCURACY_GOOD) else if (posRes == LE_OK && scan.hAccuracy <= HACCURACY_GOOD)
{ {
PackJson(GPS, &scan, json, sizeof(json)); PackJson(GPS, &scan, json, sizeof(json));
psensor_PushJson(ref, 0 /* now */, json); psensor_PushJson(ref, 0 /* now */, json);
// Kill any errant WIFI sacn requests as we got GPS // Kill any errant WIFI sacn requests as we got GPS
if (State.waitingForWifiResults) if (State.waitingForWifiResults)
State.waitingForWifiResults = false; State.waitingForWifiResults = false;
} }
else else
...@@ -454,6 +458,6 @@ COMPONENT_INIT ...@@ -454,6 +458,6 @@ COMPONENT_INIT
psensor_Create("coordinates", DHUBIO_DATA_TYPE_JSON, "", Sample); psensor_Create("coordinates", DHUBIO_DATA_TYPE_JSON, "", Sample);
dhubIO_SetJsonExample("coordinates/value", "{\"lat\":0.1,\"lon\":0.2," dhubIO_SetJsonExample("coordinates/value", "{\"lat\":0.1,\"lon\":0.2,"
"\"alt\":0.3,\"hAcc\":0.4,\"vAcc\":0.5,\"fixType\":\"GNSS\"}"); "\"alt\":0.3,\"hAcc\":0.4,\"vAcc\":0.5,\"fixType\":\"GNSS\"}");
} }
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