Commit 912a3a47 authored by Inho Oh's avatar Inho Oh

examples/OCFSecure: Add ARTIK board

This patch add the ARTIK board to the list of supported devices.
The blue LED on board (GPIO38) is used for switch resource in the server
program. And the GPIO is controlled by "mraa" library which already used
in the server program.

The "mraa" library is not support the ARTIK board. So to use the raw GPIO
pin number, "raw=true" option is added.

Change-Id: I2004bc473c64189f3cc1010ae76c4cfe757b33f5
Signed-off-by: default avatarInho Oh <webispy@gmail.com>
parent 8e30527a
......@@ -52,9 +52,15 @@ joule = 'Linux' in platform_info and 'joule' in platform_info and \
raspberry_pi = 'Linux' in platform_info and \
('armv7l' in platform_info or 'armv6l' in platform_info) and \
'debian' in platform_info
if joule or raspberry_pi:
if os.path.exists("/proc/device-tree/model"):
with open("/proc/device-tree/model") as f:
model = f.read()
artik = 'artik' in model or 'compy' in model
else:
artik = False
if joule or raspberry_pi or artik:
conf = Configure(env)
if not conf.CheckCXXHeader('mraa.hpp'):
if not conf.CheckLib('mraa'):
print("required library mraa not installed! ")
if joule and not raspberry_pi:
print(" To install mraa\n\
......@@ -62,7 +68,7 @@ if joule or raspberry_pi:
$sudo apt-get update\n\
$sudo apt-get install libmraa1 libmraa-dev\
mraa-tools python-mraa python3-mraa\n")
elif not joule and raspberry_pi:
elif not joule and (raspberry_pi or artik):
print("to install mraa\n\
$git clone https://github.com/intel-iot-devkit/\
mraa.git ../mraa\n\
......@@ -74,9 +80,12 @@ if joule or raspberry_pi:
cpp_defines.append('WITH_MRAA')
libraries.append('mraa')
if joule and not raspberry_pi:
cpp_defines.append('JOULE')
cpp_defines.append('LED_PIN=100')
elif not joule and raspberry_pi:
cpp_defines.append('RASPBERRY')
cpp_defines.append('LED_PIN=7')
elif artik:
cpp_defines.append('LED_PIN=38')
cpp_defines.append('RAW_GPIO')
else:
print "ERROR: unknown board"
conf.Finish()
......
......@@ -40,12 +40,6 @@
static bool STOP = false;
static char SVR_DB[] = "ocf_svr_db_server.dat";
static char INTROSPECTION_FILE[] = "switch_introspection.dat";
#ifdef JOULE
int LED_PIN = 100; // built-in led on the intel joule board
#endif
#ifdef RASPBERRY
int LED_PIN = 7;
#endif
#ifdef WITH_MRAA
mraa::Gpio *GPIO;
#endif
......@@ -273,9 +267,9 @@ ProcessPostRequest(OCEntityHandlerRequest *ehRequest,
if (OCRepPayloadGetPropBool(requestPayload, "value", &value))
{
SWITCH.value = value;
#if defined(JOULE) || defined(RASPBERRY)
#ifdef WITH_MRAA
GPIO->write(value);
#endif
#endif
}
else
{
......@@ -466,9 +460,12 @@ int
main(void)
{
OCStackResult stack_res = OC_STACK_ERROR;
// enabling GPIO if running on the Intel Joule or the raspberry pi
#if (defined(JOULE) || defined(RASPBERRY)) && defined(WITH_MRAA)
#if defined(WITH_MRAA)
#if defined(RAW_GPIO)
GPIO = new mraa::Gpio(LED_PIN, true, true);
#else
GPIO = new mraa::Gpio(LED_PIN);
#endif
if (!GPIO)
{
OIC_LOG_V(ERROR, TAG, "Error instantiating gpio %d", LED_PIN);
......
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