BigW Consortium Gitlab

Commit d6d04f0b by David Clark

Merge branch 'master' of ssh://github.com/mangOH/mangOH

parents f4da3719 3ee97de2
Subproject commit 76f7560f98cb96b7e3f05797cfbdee0ed3f42c6b Subproject commit 699e500ad32aaad5799a8b7e7b4244f67a13407a
Subproject commit e4ae027c9f447f84723f3fc1c872875166840cfa Subproject commit e8395ae650c66c1ce044b7da7ea77a1e5e366171
Subproject commit 84b40089f470cd0574ca72bf1943c3bcb6f2842d Subproject commit 96ca0364ccaf4c5ff8c7d6feaeb984c6958a6cf1
Subproject commit 6966f104db935ff771dcce229647255f0bb01fa2 Subproject commit 5b471995d594827c55cb7939b7e048b207080d68
Subproject commit 3c5de16d8c8390eb56b4961273877da43773f888 Subproject commit 6b24c67721832748c25d9a62751690afe52ed6fc
Subproject commit 24f0dc8aa1e2c19a6ac272d65be8a2e3085472e6 Subproject commit e71865bdd0cf367c99cdbaf62328ae230122ff27
Subproject commit 60da5e1c03b694ce9b45ccd61f67a4bfa3f0fee2 Subproject commit a16c7383f9077cde0249802931af12802313af2d
Subproject commit 7f669131d16ce30e05ef8406651a7a0965a6b8a4 Subproject commit d9bc976e11679435d53734538b96cdd69c84856a
...@@ -31,6 +31,14 @@ commands: ...@@ -31,6 +31,14 @@ commands:
twitter = socialService:/bin/twitter twitter = socialService:/bin/twitter
} }
interfaceSearch:
{
$MANGOH_ROOT/apps/MqttClient
$MANGOH_ROOT/apps/DataRouter
$MANGOH_ROOT/apps/MuxControl
$MANGOH_ROOT/apps/SocialService/interfaces
}
kernelModules: kernelModules:
{ {
$MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_green_dv4 $MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_green_dv4
......
...@@ -31,6 +31,13 @@ commands: ...@@ -31,6 +31,13 @@ commands:
twitter = socialService:/bin/twitter twitter = socialService:/bin/twitter
} }
interfaceSearch:
{
$MANGOH_ROOT/apps/MqttClient
$MANGOH_ROOT/apps/DataRouter
$MANGOH_ROOT/apps/MuxControl
$MANGOH_ROOT/apps/SocialService/interfaces
}
kernelModules: kernelModules:
{ {
......
Subproject commit 76962746606a8360c2030476ab8e25d072743a99 Subproject commit 74a620c30e78d56f0e38d1d752cd829df963a112
Subproject commit d8b9d40379bbc3ebdd12cb6a3e812283f6589253 Subproject commit 024ec5e45b5771a83c763a1d8125f6eaf83d02a8
...@@ -2,12 +2,12 @@ requires: ...@@ -2,12 +2,12 @@ requires:
{ {
api: api:
{ {
${MANGOH_ROOT}/apps/SocialService/interfaces/twitter.api twitter.api
le_ulpm.api le_ulpm.api
le_bootReason.api le_bootReason.api
le_adc.api le_adc.api
le_data.api le_data.api
airVantage/legacy/le_avdata.api airVantage/le_avdata.api
modemServices/le_info.api modemServices/le_info.api
} }
} }
...@@ -22,14 +22,3 @@ cxxflags: ...@@ -22,14 +22,3 @@ cxxflags:
{ {
-std=c++11 -std=c++11
} }
assets:
{
LightSensor =
{
variables:
{
int Reading
}
}
}
\ No newline at end of file
...@@ -21,12 +21,24 @@ ...@@ -21,12 +21,24 @@
#define LIGHT_SENSOR_SAMPLE_INTERVAL_MS 2000 #define LIGHT_SENSOR_SAMPLE_INTERVAL_MS 2000
static void SendTweet(const char* tweet);
static void LightSensorSampleTimerHandler(le_timer_Ref_t sampleTimer);
static void PushCallbackHandler(le_avdata_PushStatus_t status, void *context);
static void AvSessionStateHandler(le_avdata_SessionState_t state, void *context);
static void TryStartTimer(void);
static const uint32_t UnicodeTiredFace = 0x1F62B; static const uint32_t UnicodeTiredFace = 0x1F62B;
static const uint32_t UnicodeSleepingFace = 0x1F634; static const uint32_t UnicodeSleepingFace = 0x1F634;
static le_avdata_RequestSessionObjRef_t AvSession;
static le_timer_Ref_t LightSensorSampleTimer; static le_timer_Ref_t LightSensorSampleTimer;
static bool TweetPending = false;
static bool AvDataSessionActive = false;
static uint32_t PushCount = 0;
static uint32_t ShutdownAfterPush = 0;
static le_avdata_AssetInstanceRef_t LightSensorAsset; static const char *LightSensorReadingResource = "lightSensor/reading";
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
...@@ -73,6 +85,7 @@ static void SendTweet ...@@ -73,6 +85,7 @@ static void SendTweet
LE_FATAL("Unhandled tweet result (%d)", r); LE_FATAL("Unhandled tweet result (%d)", r);
} }
} while (attempts < 3); } while (attempts < 3);
TweetPending = false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
...@@ -98,15 +111,50 @@ static void LightSensorSampleTimerHandler ...@@ -98,15 +111,50 @@ static void LightSensorSampleTimerHandler
LE_DEBUG("Light sensor reports value %d", lightSensorReading); LE_DEBUG("Light sensor reports value %d", lightSensorReading);
} }
le_avdata_SetInt(LightSensorAsset, "Reading", lightSensorReading);
if (lightSensorReading < ADC_LEVEL_SLEEP) if (lightSensorReading < ADC_LEVEL_SLEEP)
{ {
ShutdownAfterPush = PushCount + 1;
LE_INFO( LE_INFO(
"Initiating shutdown due to light sensor value %d which is below the minimum %d", "Initiating shutdown due to light sensor value %d which is below the minimum %d",
lightSensorReading, lightSensorReading,
ADC_LEVEL_SLEEP); ADC_LEVEL_SLEEP);
}
auto setIntRes = le_avdata_SetInt(LightSensorReadingResource, lightSensorReading);
if (setIntRes != LE_OK)
{
LE_WARN("Failed to set light sensor resource");
}
else
{
PushCount++;
le_avdata_Push(LightSensorReadingResource, PushCallbackHandler, (void *)PushCount);
}
}
static void PushCallbackHandler
(
le_avdata_PushStatus_t status, ///< push status
void *context ///< The push count when the push was submitted
)
{
switch (status)
{
case LE_AVDATA_PUSH_SUCCESS:
break;
case LE_AVDATA_PUSH_FAILED:
LE_WARN("Failed to push push_button state");
break;
default:
LE_FATAL("Unexpected push status");
break;
}
if ((uint32_t)context == ShutdownAfterPush)
{
if (le_ulpm_BootOnAdc( if (le_ulpm_BootOnAdc(
LIGHT_SENSOR_ADC_NUM, LIGHT_SENSOR_ADC_NUM,
LIGHT_SENSOR_SAMPLE_INTERVAL_MS, LIGHT_SENSOR_SAMPLE_INTERVAL_MS,
...@@ -139,12 +187,51 @@ static void LightSensorSampleTimerHandler ...@@ -139,12 +187,51 @@ static void LightSensorSampleTimerHandler
} }
} }
static void AvSessionStateHandler
(
le_avdata_SessionState_t state,
void *context
)
{
switch (state)
{
case LE_AVDATA_SESSION_STARTED:
LE_DEBUG("AVData session started");
AvDataSessionActive = true;
TryStartTimer();
break;
case LE_AVDATA_SESSION_STOPPED:
LE_INFO("AVData session stopped. Push will fail.");
AvDataSessionActive = false;
le_timer_Stop(LightSensorSampleTimer);
break;
default:
LE_FATAL("Unsupported AV session state %d", state);
break;
}
}
static void TryStartTimer(void)
{
if (AvDataSessionActive && !TweetPending)
{
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer));
}
}
COMPONENT_INIT COMPONENT_INIT
{ {
LE_DEBUG("wakeupAndTweetApp started"); LE_DEBUG("wakeupAndTweetApp started");
LightSensorAsset = le_avdata_Create("LightSensor"); le_result_t r = le_avdata_CreateResource(LightSensorReadingResource, LE_AVDATA_ACCESS_VARIABLE);
LE_FATAL_IF(r != LE_OK && r != LE_DUPLICATE, "Couldn't create resource for light sensor reading");
le_avdata_AddSessionStateHandler(AvSessionStateHandler, NULL);
AvSession = le_avdata_RequestSession();
LE_FATAL_IF(AvSession == NULL, "Failed to request avdata session");
LightSensorSampleTimer = le_timer_Create("light sensor"); LightSensorSampleTimer = le_timer_Create("light sensor");
LE_ASSERT_OK(le_timer_SetHandler(LightSensorSampleTimer, LightSensorSampleTimerHandler)); LE_ASSERT_OK(le_timer_SetHandler(LightSensorSampleTimer, LightSensorSampleTimerHandler));
...@@ -168,18 +255,20 @@ COMPONENT_INIT ...@@ -168,18 +255,20 @@ COMPONENT_INIT
std::ostringstream tweetStream; std::ostringstream tweetStream;
tweetStream << emoji << " mangOH with IMEI=" << imei << " has woken up at " << dateTime; tweetStream << emoji << " mangOH with IMEI=" << imei << " has woken up at " << dateTime;
auto tweet = std::make_shared<std::string>(tweetStream.str()); auto tweet = std::make_shared<std::string>(tweetStream.str());
TweetPending = true;
if (wakeupAndTweet_ConnectAndRun([tweet]{ if (wakeupAndTweet_ConnectAndRun([tweet]{
SendTweet(tweet->c_str()); SendTweet(tweet->c_str());
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer)); TryStartTimer();
}) != LE_OK) }) != LE_OK)
{ {
TweetPending = false;
LE_ERROR("Couldn't create data connection to send tweet"); LE_ERROR("Couldn't create data connection to send tweet");
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer)); TryStartTimer();
} }
} }
else else
{ {
LE_DEBUG("Boot reason was not ADC %u", LIGHT_SENSOR_ADC_NUM); LE_DEBUG("Boot reason was not ADC %u", LIGHT_SENSOR_ADC_NUM);
LE_ASSERT_OK(le_timer_Start(LightSensorSampleTimer)); TryStartTimer();
} }
} }
...@@ -5,47 +5,20 @@ ...@@ -5,47 +5,20 @@
// Copyright (C) Sierra Wireless Inc. Use of this work is subject to license. // Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
#include "$LEGATO_ROOT/default.sdef"
apps: apps:
{ {
// Platform services.
$LEGATO_SERVICE_AVC_APP
$LEGATO_ROOT/apps/platformServices/cellNetService
$LEGATO_ROOT/apps/platformServices/dataConnectionService
$LEGATO_ROOT/apps/platformServices/fwupdateService
$LEGATO_ROOT/apps/platformServices/modemService
$LEGATO_ROOT/apps/platformServices/positioningService
$LEGATO_ROOT/apps/platformServices/powerMgr
$LEGATO_ROOT/apps/platformServices/secStore
$LEGATO_ROOT/apps/platformServices/gpioService
$LEGATO_ROOT/apps/platformServices/fsService
$LEGATO_ROOT/apps/sample/lwm2mAirVantageControl/lwm2mControl
$MANGOH_ROOT/apps/SocialService/socialService $MANGOH_ROOT/apps/SocialService/socialService
// Command-line tools.
$LEGATO_ROOT/apps/tools/tools
$MANGOH_ROOT/samples/tutorials/developerDay2016/apps/wakeupAndTweet $MANGOH_ROOT/samples/tutorials/developerDay2016/apps/wakeupAndTweet
} }
commands: commands:
{ {
cm = tools:/scripts/cm
fwupdate = tools:/bin/fwupdate
secstore = tools:/bin/secstore
pmtool = tools:/bin/pmtool
twitter = socialService:/bin/twitter twitter = socialService:/bin/twitter
} }
bindings:
{
<root>.le_fwupdate -> fwupdateService.le_fwupdate
}
interfaceSearch: interfaceSearch:
{ {
interfaces/modemServices $MANGOH_ROOT/apps/SocialService/interfaces
interfaces/positioning
} }
...@@ -2,7 +2,7 @@ requires: ...@@ -2,7 +2,7 @@ requires:
{ {
api: api:
{ {
${LEGATO_ROOT}/interfaces/modemServices/le_adc.api modemServices/le_adc.api
} }
} }
......
...@@ -2,8 +2,8 @@ requires: ...@@ -2,8 +2,8 @@ requires:
{ {
api: api:
{ {
le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api le_sensorGpio = le_gpio.api
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio =le_gpio.api
} }
} }
......
...@@ -2,7 +2,7 @@ requires: ...@@ -2,7 +2,7 @@ requires:
{ {
api: api:
{ {
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = le_gpio.api
} }
} }
......
...@@ -2,8 +2,8 @@ requires: ...@@ -2,8 +2,8 @@ requires:
{ {
api: api:
{ {
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = le_gpio.api
mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_pushButton = le_gpio.api
} }
} }
......
...@@ -2,7 +2,7 @@ requires: ...@@ -2,7 +2,7 @@ requires:
{ {
api: api:
{ {
${LEGATO_ROOT}/interfaces/modemServices/le_adc.api modemServices/le_adc.api
} }
} }
......
...@@ -2,8 +2,8 @@ requires: ...@@ -2,8 +2,8 @@ requires:
{ {
api: api:
{ {
le_sensorGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api le_sensorGpio = le_gpio.api
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = le_gpio.api
} }
} }
......
...@@ -2,7 +2,7 @@ requires: ...@@ -2,7 +2,7 @@ requires:
{ {
api: api:
{ {
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = le_gpio.api
} }
} }
......
...@@ -2,8 +2,8 @@ requires: ...@@ -2,8 +2,8 @@ requires:
{ {
api: api:
{ {
mangoh_ledGpio = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_ledGpio = le_gpio.api
mangoh_pushButton = ${LEGATO_ROOT}/interfaces/le_gpio.api mangoh_pushButton = le_gpio.api
} }
} }
......
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