Migrate to LED HAL (IPSO Objects)

This commit is contained in:
George Oikonomou 2018-02-25 21:40:19 +00:00
parent db058b166c
commit a1b9ba2630
3 changed files with 10 additions and 4 deletions

View File

@ -46,6 +46,7 @@
#include "services/ipso-objects/ipso-objects.h"
#include "services/ipso-objects/ipso-sensor-template.h"
#include "services/ipso-objects/ipso-control-template.h"
#include "dev/leds.h"
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
@ -98,9 +99,9 @@ static lwm2m_status_t
leds_set_val(ipso_control_t *control, uint8_t value)
{
if(value > 0) {
leds_on(LEDS_YELLOW);
leds_single_on(LEDS_LED1);
} else {
leds_off(LEDS_YELLOW);
leds_single_off(LEDS_LED1);
}
return LWM2M_STATUS_OK;
}

View File

@ -56,11 +56,15 @@
#define PRINTF(...)
#endif
#if LEDS_LEGACY_API
#if LEDS_ALL & LEDS_BLUE || LEDS_ALL & LEDS_RED || LEDS_ALL & LEDS_BLUE
#define LEDS_CONTROL_NUMBER (((LEDS_ALL & LEDS_BLUE) ? 1 : 0) + ((LEDS_ALL & LEDS_RED) ? 1 : 0) + ((LEDS_ALL & LEDS_GREEN) ? 1 : 0))
#else
#define LEDS_CONTROL_NUMBER 1
#endif
#else /* LEDS_LEGACY_API */
#define LEDS_CONTROL_NUMBER LEDS_COUNT
#endif /* LEDS_LEGACY_API */
typedef struct led_state {
ipso_control_t control;
@ -72,7 +76,7 @@ static led_state_t leds_controls[LEDS_CONTROL_NUMBER];
static lwm2m_status_t
set_value(ipso_control_t *control, uint8_t value)
{
#if PLATFORM_HAS_LEDS
#if PLATFORM_HAS_LEDS || LEDS_COUNT
led_state_t *state;
state = (led_state_t *)control;

View File

@ -42,6 +42,7 @@
*/
#include "contiki.h"
#include "dev/leds.h"
#include "ipso-objects.h"
/*---------------------------------------------------------------------------*/
void
@ -58,7 +59,7 @@ ipso_objects_init(void)
#ifdef IPSO_LIGHT_CONTROL
ipso_light_control_init();
#elif PLATFORM_HAS_LEDS
#elif PLATFORM_HAS_LEDS || LEDS_COUNT
ipso_leds_control_init();
#endif
}