BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mangoh-drivers
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
mangoh-drivers
Commits
dc71830c
Commit
dc71830c
authored
Sep 06, 2017
by
David Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ButtonToAirVantage sample app
parent
73bc58f8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
162 additions
and
0 deletions
+162
-0
LICENSE.txt
...ials/mangOH_Red/AirVantage/ButtonToAirVantage/LICENSE.txt
+0
-0
buttonToAirVantage.adef
...Red/AirVantage/ButtonToAirVantage/buttonToAirVantage.adef
+28
-0
Component.cdef
...onToAirVantage/buttonToAirVantageComponent/Component.cdef
+13
-0
buttonToAirVantage.c
...rVantage/buttonToAirVantageComponent/buttonToAirVantage.c
+121
-0
No files found.
samples/tutorials/mangOH_Red/AirVantage/ButtonToAirVantage/LICENSE.txt
0 → 100644
View file @
dc71830c
This diff is collapsed.
Click to expand it.
samples/tutorials/mangOH_Red/AirVantage/ButtonToAirVantage/buttonToAirVantage.adef
0 → 100644
View file @
dc71830c
sandboxed: true
version: 1.0.0
start: auto
executables:
{
buttonToAirVantage = ( buttonToAirVantageComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = INFO
}
run:
{
( buttonToAirVantage )
}
faultAction: restart
}
bindings:
{
buttonToAirVantage.buttonToAirVantageComponent.mangoh_button -> gpioExpanderServiceRed.mangoh_gpioExpPin14
buttonToAirVantage.buttonToAirVantageComponent.le_avdata -> avcService.le_avdata
}
samples/tutorials/mangOH_Red/AirVantage/ButtonToAirVantage/buttonToAirVantageComponent/Component.cdef
0 → 100644
View file @
dc71830c
requires:
{
api:
{
mangoh_button = le_gpio.api
airVantage/le_avdata.api
}
}
sources:
{
buttonToAirVantage.c
}
samples/tutorials/mangOH_Red/AirVantage/ButtonToAirVantage/buttonToAirVantageComponent/buttonToAirVantage.c
0 → 100644
View file @
dc71830c
/**
* @file
*
* Publishes the push button state to AirVantage.
*
* <HR>
*
* Copyright (C) Sierra Wireless, Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
static
const
char
PushButtonResource
[]
=
"/push_button"
;
static
le_avdata_RequestSessionObjRef_t
AvSession
;
static
le_avdata_SessionStateHandlerRef_t
SessionStateHandlerRef
;
static
void
PushCallbackHandler
(
le_avdata_PushStatus_t
status
,
///< push status
void
*
context
///< Unused context pointer
)
{
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
;
}
}
//--------------------------------------------------------------------------------------------------
/**
* Publish the push button state to AirVantage as a boolean.
*/
//--------------------------------------------------------------------------------------------------
static
void
PushButtonHandler
(
bool
state
,
///< true if the button is pressed
void
*
ctx
///< context pointer - not used
)
{
if
(
state
)
{
LE_DEBUG
(
"Button was pressed"
);
}
else
{
LE_DEBUG
(
"Button was released"
);
}
le_result_t
res
=
res
=
le_avdata_SetBool
(
PushButtonResource
,
state
);
if
(
res
!=
LE_OK
)
{
LE_WARN
(
"Failed to set push_button resource"
);
}
else
{
le_avdata_Push
(
PushButtonResource
,
PushCallbackHandler
,
NULL
);
}
}
//--------------------------------------------------------------------------------------------------
/**
* Configure the push button input
*/
//--------------------------------------------------------------------------------------------------
static
void
ConfigureGpios
(
void
)
{
// Set the push-button GPIO as input
LE_FATAL_IF
(
mangoh_button_SetInput
(
MANGOH_BUTTON_ACTIVE_LOW
)
!=
LE_OK
,
"Couldn't configure push button as input"
);
mangoh_button_AddChangeEventHandler
(
MANGOH_BUTTON_EDGE_BOTH
,
PushButtonHandler
,
NULL
,
0
);
}
static
void
AvSessionStateHandler
(
le_avdata_SessionState_t
state
,
void
*
context
)
{
switch
(
state
)
{
case
LE_AVDATA_SESSION_STARTED
:
{
le_result_t
res
=
le_avdata_CreateResource
(
PushButtonResource
,
LE_AVDATA_ACCESS_VARIABLE
);
if
(
res
!=
LE_OK
&&
res
!=
LE_DUPLICATE
)
{
LE_FATAL
(
"Couldn't create push_button variable resource"
);
}
break
;
}
case
LE_AVDATA_SESSION_STOPPED
:
LE_INFO
(
"AVData session stopped. Push will fail."
);
break
;
default:
LE_FATAL
(
"Unsupported AV session state %d"
,
state
);
break
;
}
}
COMPONENT_INIT
{
ConfigureGpios
();
SessionStateHandlerRef
=
le_avdata_AddSessionStateHandler
(
AvSessionStateHandler
,
NULL
);
AvSession
=
le_avdata_RequestSession
();
LE_FATAL_IF
(
AvSession
==
NULL
,
"Failed to request avdata session"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment