BigW Consortium Gitlab

Commit dbf21c66 by David Frey

Do not start AV session since lwm2mControl starts it

parent b1c86963
version: 2.0
version: 1.1
sandboxed: true
start: auto
......
......@@ -26,8 +26,6 @@ static const uint32_t UnicodeSleepingFace = 0x1F634;
static le_timer_Ref_t LightSensorSampleTimer;
static bool TweetPending;
static bool AvConnecting;
static le_avdata_AssetInstanceRef_t LightSensorAsset;
......@@ -150,52 +148,12 @@ static void LightSensorSampleTimerHandler
}
}
static bool TryStartTimer(void)
{
const bool start = (!TweetPending && !AvConnecting);
if (start)
{
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer));
}
return start;
}
static void AvDataSessionStateHandler
(
le_avdata_SessionState_t sessionState,
void* contextPtr
)
{
switch (sessionState)
{
case LE_AVDATA_SESSION_STARTED:
LE_DEBUG("AV data session started");
AvConnecting = false;
LightSensorAsset = le_avdata_Create("LightSensor");
TryStartTimer();
break;
case LE_AVDATA_SESSION_STOPPED:
LE_WARN("AirVantage session has stopped, but this was not requested");
break;
default:
LE_FATAL("Unhandled AV data session state (%d)", sessionState);
break;
}
}
COMPONENT_INIT
{
LE_DEBUG("wakeupAndTweetApp started");
TweetPending = true;
AvConnecting = true;
le_avdata_AddSessionStateHandler(AvDataSessionStateHandler, NULL);
le_avdata_RequestSession();
LightSensorAsset = le_avdata_Create("LightSensor");
LightSensorSampleTimer = le_timer_Create("light sensor");
LE_ASSERT_OK(le_timer_SetHandler(LightSensorSampleTimer, LightSensorSampleTimerHandler));
......@@ -205,7 +163,6 @@ COMPONENT_INIT
if (le_bootReason_WasAdc(LIGHT_SENSOR_ADC_NUM))
{
TweetPending = true;
LE_DEBUG("Boot reason was ADC %u", LIGHT_SENSOR_ADC_NUM);
size_t emojiLength = 4;
char emoji[emojiLength] = {0};
......@@ -216,17 +173,16 @@ COMPONENT_INIT
auto tweet = std::make_shared<std::string>(tweetStream.str());
if (wakeupAndTweet_ConnectAndRun([tweet]{
SendTweet(tweet->c_str());
TweetPending = false;
TryStartTimer();
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer));
}) != LE_OK)
{
LE_ERROR("Couldn't create data connection to send tweet");
TweetPending = false;
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer));
}
}
else
{
LE_DEBUG("Boot reason was not ADC %u", LIGHT_SENSOR_ADC_NUM);
TweetPending = false;
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer));
}
}
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