Nordic Thingy:52
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
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   1
 
#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...
 
typedef PACKED (union{PACKED(struct{uint8_t r;uint8_t g;uint8_t b;}) mode_const;PACKED(struct{uint8_tcolor_mix;uint8_tintensity;uint16_t delay;}) mode_breathe;PACKED(struct{uint8_t color_mix;uint8_t intensity;}) mode_breathe_one_shot;}) ble_uis_led_data_t
 union representing LED BLE characteristics.
 
typedef PACKED (struct{ble_uis_led_mode_t mode;ble_uis_led_data_t data;}) ble_uis_led_t
 The LED mode and data, editable over BLE.
 
typedef PACKED (struct{uint8_t mos_1;uint8_t mos_2;uint8_t mos_3;uint8_t mos_4;}) ble_uis_pin_t
 Data structure for the PIN characteristic. Controls the Metal Oxide Semiconductors (transistors).
 

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

#define BLE_UIS_LED_COLOR_MIX_MAX   7

Maximum value for color mix.

#define BLE_UIS_LED_COLOR_MIX_MIN   1

Minimum value for color mix.

#define BLE_UIS_LED_DELAY_MAX   10000

Maximum delay for breathe sequence.

#define BLE_UIS_LED_DELAY_MIN   1

Minimum delay for breathe sequence.

#define BLE_UIS_LED_INTENSITY_MAX   100

Maximum LED intensity.

#define BLE_UIS_LED_INTENSITY_MIN   1

Minimum LED intensity.

#define BLE_UIS_LED_MODE_BREATHE_LENGTH   5

Breahte mode command length in bytes.

#define BLE_UIS_LED_MODE_BREATHE_ONE_SHOT_LENGTH   3

One shot mode command length in bytes.

#define BLE_UIS_LED_MODE_CONST_LENGTH   4

Const mode command length in bytes.

#define BLE_UIS_LED_MODE_MAX   BLE_UIS_LED_MODE_BREATHE_ONE_SHOT

Maximum value for mode.

#define BLE_UIS_LED_MODE_MIN   BLE_UIS_LED_MODE_OFF

Minimum value for mode.

#define BLE_UIS_LED_MODE_OFF_LENGTH   1

Off mode command length in bytes.

#define BLE_UIS_UUID_BUTTON_CHAR   0x0302

UUID for button characteristic.

#define BLE_UIS_UUID_LED_CHAR   0x0301

UUID for LED characteristic.

#define BLE_UIS_UUID_PIN_CHAR   0x0303

UUID for pin characteristic.

#define BLE_UIS_UUID_SERVICE   0x0300

UUID for UI service

Enumeration Type Documentation

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

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.
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.
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]button_stateNew button state.
Return values
NRF_SUCCESSIf the notification was sent successfully. Otherwise, an error code is returned.