BigW Consortium Gitlab

Commit 4d4866a2 by David Frey

fix double advertise bug

Fix a problem where the OpenWeatherMap ambient temperature service would try to advertise the service each time a data connection was established. This caused a crash the second time the connection was established.
parent a6ebe223
......@@ -20,6 +20,7 @@ static struct
double temperature;
} LastResult;
static le_data_RequestObjRef_t DataRequest = NULL;
static bool AmbientTemperatureServiceAdvertised = false;
static int64_t GetTimestampNs(void)
{
......@@ -70,7 +71,11 @@ static void DcsStateHandler
{
LE_INFO("Data connection established using interface %s", intfName);
// Now that we have a connection, advertise the ambient temperature service
mangOH_ambientTemperature_AdvertiseService();
if (!AmbientTemperatureServiceAdvertised)
{
AmbientTemperatureServiceAdvertised = true;
mangOH_ambientTemperature_AdvertiseService();
}
}
else
{
......@@ -87,5 +92,6 @@ COMPONENT_INIT
"Failed to read OpenWeatherMap API Key from config tree");
le_data_AddConnectionStateHandler(DcsStateHandler, NULL);
LE_DEBUG("Requesting data connection");
DataRequest = le_data_Request();
}
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