Developing with ZBOSS for Zigbee

LED

enum  zb_led_blink_frequency_e { ZB_LED_BLINK_QUATER_SEC = 1, ZB_LED_BLINK_HALF_SEC = 2, ZB_LED_BLINK_PER_SEC = 4, ZB_LED_BLINK_PER_2SEC = 8 }
 
typedef enum zb_led_blink_frequency_e zb_led_blink_frequency_t
 
void zb_led_init (void) ZB_DEPRECATED
 
void zb_led_blink_off (zb_uint8_t led_arg)
 
void zb_led_blink_on (zb_uint8_t led_arg)
 
#define ZB_LED_PERIOD_MULTIPLIER   ZB_MILLISECONDS_TO_BEACON_INTERVAL(250U)
 
#define ZB_LED_ARG_CREATE(num, period)   ((num) | (period << 4U))
 Construct argument to pass to LEd functions line zb_led_blink_on() More...
 

Buttons

void zb_button_on_cb (zb_uint8_t butt_no)
 Set state of given button to on. More...
 
void zb_button_off_cb (zb_uint8_t butt_no)
 Set state of given button to off and invoke button handler. More...
 
void zb_button_register_handler (zb_uint8_t butt_no, zb_uint8_t pressed_sec_pow2, zb_callback_t cb)
 Register handler to be called on button release. More...
 
void zb_osif_led_on (zb_uint8_t led_no)
 Set state of given LED to "On".
 
void zb_osif_led_off (zb_uint8_t led_no)
 Set state of given LED to "Off".
 
#define ZB_BOARD_BUTTON_0   0U
 
#define ZB_BOARD_BUTTON_1   1U
 
#define ZB_BOARD_BUTTON_2   2U
 
#define ZB_BOARD_BUTTON_3   3U
 
#define ZB_BUTT_N_CBS   5U
 
#define ZB_N_BUTTONS   1U
 
#define ZB_N_LEDS   1U
 

Detailed Description

LED/Button API consists of platform-independent logic and platform API. If LEDs/Buttons are supported in particular ZBOSS build, both layers are included. If LEDs/Buttons support is not included into ZBOSS HAL, higher level is also absent. A user cannot modify low level LED/Button access API.

An application can register callbacks for button ON and off. Use zb_button_register_handler() to register callbacks.

LEDs can be switched on and off using zb_osif_led_on()/zb_osif_led_off() calls.

LED blinking is a popular function used by a final application. To simplify its implementation, ZBOSS provides it as part of the SDK. It is possible to control LED blinking using zb_led_blink_on() and zb_led_blink_off() API calls. LED blinking functionality utilizes ZBOSS multitasking, so it can be used only after zboss_startxxx() call is done and ZBOSS main loop is started.

Macro Definition Documentation

◆ ZB_BUTT_N_CBS

#define ZB_BUTT_N_CBS   5U

Number of handler that can be associated with a button.

Each of those handlers corresponds to its own press duration

◆ ZB_LED_ARG_CREATE

#define ZB_LED_ARG_CREATE (   num,
  period 
)    ((num) | (period << 4U))

Construct argument to pass to LEd functions line zb_led_blink_on()

Parameters
num- number of LED for which command is meant
period- interval between LED state changes. see ZB_LED_PERIOD_MULTIPLIER for quant size.
Note
period should not exceed value of 16

◆ ZB_LED_PERIOD_MULTIPLIER

#define ZB_LED_PERIOD_MULTIPLIER   ZB_MILLISECONDS_TO_BEACON_INTERVAL(250U)

Quant size for intervals passed to ZBOSS LED functions.

See ZB_LED_ARG_CREATE()

◆ ZB_N_BUTTONS

#define ZB_N_BUTTONS   1U

Number of button utilized by application

◆ ZB_N_LEDS

#define ZB_N_LEDS   1U

Number of leds utilized by application

Typedef Documentation

◆ zb_led_blink_frequency_t

Conveniency constants to be used with ZB_LED_ARG_CREATE() macro

Enumeration Type Documentation

◆ zb_led_blink_frequency_e

Conveniency constants to be used with ZB_LED_ARG_CREATE() macro

Enumerator
ZB_LED_BLINK_QUATER_SEC 

Blink four times per second

ZB_LED_BLINK_HALF_SEC 

Blink twice per second

ZB_LED_BLINK_PER_SEC 

Blink every second

ZB_LED_BLINK_PER_2SEC 

Blink every two seconds

Function Documentation

◆ zb_button_off_cb()

void zb_button_off_cb ( zb_uint8_t  butt_no)

Set state of given button to off and invoke button handler.

Handler to invoke is chosen by botton and duration of button press. See zb_button_register_handler() for how to setup button handlers

Parameters
butt_no- number of button being released

◆ zb_button_on_cb()

void zb_button_on_cb ( zb_uint8_t  butt_no)

Set state of given button to on.

Parameters
butt_no- number of button being pressed

◆ zb_button_register_handler()

void zb_button_register_handler ( zb_uint8_t  butt_no,
zb_uint8_t  pressed_sec_pow2,
zb_callback_t  cb 
)

Register handler to be called on button release.

Several handlers can be set for one button (see ZB_BUTT_N_CBS for maximum number of callbacks) Each handler is associated with handler press duration, and only one will be called, it depends on how long button was pressed which one.

Parameters
butt_no- number of button with which handler is associated
pressed_sec_pow2- duration with which handler is associated. calculated as given power of 2 (in sec): 1-2-4-8... sec
cb- pointer to handler functions

◆ zb_led_blink_off()

void zb_led_blink_off ( zb_uint8_t  led_arg)

Stop blinking on given LED

See ZB_LED_ARG_CREATE() for constructing led_arg

◆ zb_led_blink_on()

void zb_led_blink_on ( zb_uint8_t  led_arg)

Start blinking on given LED

See ZB_LED_ARG_CREATE() for constructing led_arg

◆ zb_led_init()

void zb_led_init ( void  )

Prepare LEDs for usage