BigW Consortium Gitlab

Commit 08a256f1 by Zahid Chowdhury

Fix bug in CombainHttp sending 2 responses for 1 request, add check for…

Fix bug in CombainHttp sending 2 responses for 1 request, add check for waitingForCombainResults all places(race?), don't ifdown wlan1 until Cypress gets back to us
parent 073647ad
...@@ -100,12 +100,13 @@ void *CombainHttpThreadFunc(void *context) ...@@ -100,12 +100,13 @@ void *CombainHttpThreadFunc(void *context)
le_event_Report(ResponseAvailableEvent, NULL, 0); le_event_Report(ResponseAvailableEvent, NULL, 0);
} }
std::string json((char*)HttpReceiveBuffer.data, HttpReceiveBuffer.used); else
{
LE_INFO("RECEIVED %d char: %s", HttpReceiveBuffer.used, (char*) HttpReceiveBuffer.data); std::string json((char*)HttpReceiveBuffer.data, HttpReceiveBuffer.used);
LE_INFO("RECEIVED %d char: %s", HttpReceiveBuffer.used, (char*) HttpReceiveBuffer.data);
ResponseJson->enqueue(std::make_tuple(handle, json)); ResponseJson->enqueue(std::make_tuple(handle, json));
le_event_Report(ResponseAvailableEvent, NULL, 0); le_event_Report(ResponseAvailableEvent, NULL, 0);
}
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
......
...@@ -294,7 +294,7 @@ static void LocationResultHandler( ...@@ -294,7 +294,7 @@ static void LocationResultHandler(
static bool TrySubmitRequest(void) static bool TrySubmitRequest(void)
{ {
if (!State.waitingForWifiResults) if (!State.waitingForWifiResults && State.waitingForCombainResults == false)
{ {
LE_INFO("Attempting to submit location request"); LE_INFO("Attempting to submit location request");
const le_result_t res = ma_combainLocation_SubmitLocationRequest( const le_result_t res = ma_combainLocation_SubmitLocationRequest(
...@@ -369,17 +369,16 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context) ...@@ -369,17 +369,16 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context)
if (res != LE_OK) if (res != LE_OK)
{ {
LE_INFO("Failed to append WiFi scan results to combain request\n"); LE_INFO("Failed to append a WiFi scan result to combain request\n");
exit(1);
} }
ap = le_wifiClient_GetNextAccessPoint(); ap = le_wifiClient_GetNextAccessPoint();
} }
if (WifiStarted) /* if (WifiStarted)
{ {
le_wifiClient_Stop(); le_wifiClient_Stop();
WifiStarted = false; WifiStarted = false;
} } */
TrySubmitRequest(); TrySubmitRequest();
} }
...@@ -388,11 +387,11 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context) ...@@ -388,11 +387,11 @@ static void WifiEventHandler(le_wifiClient_Event_t event, void *context)
default: default:
{ {
LE_INFO("WiFi scan failed\n"); LE_INFO("WiFi scan failed\n");
if (WifiStarted) /*if (WifiStarted)
{ {
le_wifiClient_Stop(); le_wifiClient_Stop();
WifiStarted = false; WifiStarted = false;
} }*/
ma_combainLocation_DestroyLocationRequest(State.combainHandle); ma_combainLocation_DestroyLocationRequest(State.combainHandle);
State.waitingForWifiResults = false; State.waitingForWifiResults = false;
UseGpsScan(); UseGpsScan();
...@@ -450,8 +449,7 @@ static void Sample ...@@ -450,8 +449,7 @@ static void Sample
GpsScan = &SavedGpsScan; GpsScan = &SavedGpsScan;
} }
if (!State.waitingForWifiResults) { if (!State.waitingForWifiResults && State.waitingForCombainResults == false) {
if (!createdAccessPoint) if (!createdAccessPoint)
{ {
createdAccessPoint = le_wifiClient_Create((const uint8_t *)ssidPtr, strlen(ssidPtr)); createdAccessPoint = le_wifiClient_Create((const uint8_t *)ssidPtr, strlen(ssidPtr));
...@@ -469,16 +467,22 @@ static void Sample ...@@ -469,16 +467,22 @@ static void Sample
} }
} }
startRes = le_wifiClient_Start(); if (WifiStarted == false) {
startRes = le_wifiClient_Start();
if (startRes != LE_OK && startRes != LE_BUSY) { if (startRes != LE_OK && startRes != LE_BUSY) {
LE_INFO("Couldn't start the WiFi service error code: %s", LE_RESULT_TXT(startRes)); LE_INFO("Couldn't start the WiFi service error code: %s", LE_RESULT_TXT(startRes));
WifiStarted = true; WifiStarted = false;
}
else
WifiStarted = true;
} }
saved_ref = ref; if (WifiStarted == true) {
le_wifiClient_Scan(); saved_ref = ref;
State.waitingForWifiResults = true; le_wifiClient_Scan();
State.waitingForWifiResults = true;
}
} }
else else
LE_INFO("le_wifiClient_Scan still RUNNING"); LE_INFO("le_wifiClient_Scan still RUNNING");
......
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