Nordic Thingy:52 v2.2.0
Thingy User Interface Service

Thingy User Interface Service module. More...

Data Structures

struct  ble_uis_init_t
 LED Button Service init structure. This structure contains all options and data needed for initialization of the service. More...
 
struct  ble_uis_s
 LED Button Service structure. This structure contains various status information for the service. More...
 

Macros

#define BLE_UIS_LED_COLOR_MIX_MAX   7
 
#define BLE_UIS_LED_COLOR_MIX_MIN   1
 
#define BLE_UIS_LED_DELAY_MAX   10000
 
#define BLE_UIS_LED_DELAY_MIN   50
 
#define BLE_UIS_LED_INTENSITY_MAX   100
 
#define BLE_UIS_LED_INTENSITY_MIN   1
 
#define BLE_UIS_LED_MODE_BREATHE_LENGTH   5
 
#define BLE_UIS_LED_MODE_BREATHE_ONE_SHOT_LENGTH   3
 
#define BLE_UIS_LED_MODE_CONST_LENGTH   4
 
#define BLE_UIS_LED_MODE_MAX   BLE_UIS_LED_MODE_BREATHE_ONE_SHOT
 
#define BLE_UIS_LED_MODE_MIN   BLE_UIS_LED_MODE_OFF
 
#define BLE_UIS_LED_MODE_OFF_LENGTH   1
 
#define BLE_UIS_UUID_BUTTON_CHAR   0x0302
 
#define BLE_UIS_UUID_LED_CHAR   0x0301
 
#define BLE_UIS_UUID_PIN_CHAR   0x0303
 
#define BLE_UIS_UUID_SERVICE   0x0300
 

Typedefs

typedef void(* ble_uis_led_write_handler_t) (ble_uis_t *p_uis, ble_uis_led_t *rgb)
 Declaring the LED write handler.
 
typedef void(* ble_uis_pin_write_handler_t) (ble_uis_t *p_uis, ble_uis_pin_t *pin)
 Declaring the pin write handler.
 
typedef struct ble_uis_s ble_uis_t
 Forward declaration of the ble_uis_t type.
 

Enumerations

enum  ble_uis_led_mode_t { BLE_UIS_LED_MODE_OFF, BLE_UIS_LED_MODE_CONST, BLE_UIS_LED_MODE_BREATHE, BLE_UIS_LED_MODE_BREATHE_ONE_SHOT }
 The available LED operation modes. More...
 

Functions

uint32_t ble_uis_init (ble_uis_t *p_uis, const ble_uis_init_t *p_uis_init)
 Function for initializing the LED Button Service. More...
 
void ble_uis_on_ble_evt (ble_uis_t *p_uis, ble_evt_t *p_ble_evt)
 Function for handling the application's BLE stack events. More...
 
uint32_t ble_uis_on_button_change (ble_uis_t *p_uis, uint8_t buttons_state)
 Function for sending a button state notification. More...
 

Detailed Description

Thingy User Interface Service module.

This module implements a custom LED Button Service with an LED and Button Characteristics. During initialization, the module adds the LED Button Service and Characteristics to the BLE stack database.

The application must supply an event handler for receiving LED Button Service events. Using this handler, the service notifies the application when the LED value changes.

The service also provides a function for letting the application notify the state of the Button Characteristic to connected peers.

Note
The application must propagate BLE stack events to the LED Button Service module by calling ble_uis_on_ble_evt() from the softdevice_handler callback.

Macro Definition Documentation

◆ BLE_UIS_LED_COLOR_MIX_MAX

#define BLE_UIS_LED_COLOR_MIX_MAX   7

Maximum value for color mix.

◆ BLE_UIS_LED_COLOR_MIX_MIN

#define BLE_UIS_LED_COLOR_MIX_MIN   1

Minimum value for color mix.

◆ BLE_UIS_LED_DELAY_MAX

#define BLE_UIS_LED_DELAY_MAX   10000

Maximum delay for breathe sequence [ms].

◆ BLE_UIS_LED_DELAY_MIN

#define BLE_UIS_LED_DELAY_MIN   50

Minimum delay for breathe sequence [ms].

◆ BLE_UIS_LED_INTENSITY_MAX

#define BLE_UIS_LED_INTENSITY_MAX   100

Maximum LED intensity.

◆ BLE_UIS_LED_INTENSITY_MIN

#define BLE_UIS_LED_INTENSITY_MIN   1

Minimum LED intensity.

◆ BLE_UIS_LED_MODE_BREATHE_LENGTH

#define BLE_UIS_LED_MODE_BREATHE_LENGTH   5

Breahte mode command length [bytes].

◆ BLE_UIS_LED_MODE_BREATHE_ONE_SHOT_LENGTH

#define BLE_UIS_LED_MODE_BREATHE_ONE_SHOT_LENGTH   3

One shot mode command length [bytes].

◆ BLE_UIS_LED_MODE_CONST_LENGTH

#define BLE_UIS_LED_MODE_CONST_LENGTH   4

Const mode command length [bytes].

◆ BLE_UIS_LED_MODE_MAX

#define BLE_UIS_LED_MODE_MAX   BLE_UIS_LED_MODE_BREATHE_ONE_SHOT

Maximum value for mode.

◆ BLE_UIS_LED_MODE_MIN

#define BLE_UIS_LED_MODE_MIN   BLE_UIS_LED_MODE_OFF

Minimum value for mode.

◆ BLE_UIS_LED_MODE_OFF_LENGTH

#define BLE_UIS_LED_MODE_OFF_LENGTH   1

Off mode command length [bytes].

◆ BLE_UIS_UUID_BUTTON_CHAR

#define BLE_UIS_UUID_BUTTON_CHAR   0x0302

UUID for button characteristic.

◆ BLE_UIS_UUID_LED_CHAR

#define BLE_UIS_UUID_LED_CHAR   0x0301

UUID for LED characteristic.

◆ BLE_UIS_UUID_PIN_CHAR

#define BLE_UIS_UUID_PIN_CHAR   0x0303

UUID for pin characteristic.

◆ BLE_UIS_UUID_SERVICE

#define BLE_UIS_UUID_SERVICE   0x0300

UUID for UI service

Enumeration Type Documentation

◆ ble_uis_led_mode_t

The available LED operation modes.

Enumerator
BLE_UIS_LED_MODE_OFF 

LED off.

BLE_UIS_LED_MODE_CONST 

LED on with a given R, G and B color mix.

BLE_UIS_LED_MODE_BREATHE 

LED breathe cycle (fade in, on, fade out, off).

BLE_UIS_LED_MODE_BREATHE_ONE_SHOT 

Similar to BREATHE, but only a single cycle is performed.

Function Documentation

◆ ble_uis_init()

uint32_t ble_uis_init ( ble_uis_t p_uis,
const ble_uis_init_t p_uis_init 
)

Function for initializing the LED Button Service.

Parameters
[out]p_uisLED Button Service structure. This structure must be supplied by the application. It is initialized by this function and will later be used to identify this particular service instance.
[in]p_uis_initInformation needed to initialize the service.
Return values
NRF_SUCCESSIf the service was initialized successfully. Otherwise, an error code is returned.

◆ ble_uis_on_ble_evt()

void ble_uis_on_ble_evt ( ble_uis_t p_uis,
ble_evt_t *  p_ble_evt 
)

Function for handling the application's BLE stack events.

This function handles all events from the BLE stack that are of interest to the LED Button Service.

Parameters
[in]p_uisLED Button Service structure.
[in]p_ble_evtEvent received from the BLE stack.

◆ ble_uis_on_button_change()

uint32_t ble_uis_on_button_change ( ble_uis_t p_uis,
uint8_t  buttons_state 
)

Function for sending a button state notification.

Parameters
[in]p_uisLED Button Service structure.
[in]buttons_stateNew button state.
Return values
NRF_SUCCESSIf the notification was sent successfully. Otherwise, an error code is returned.