Nordic Thingy:52
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Thingy Motion Service

Thingy Motion Service implementation. More...

Data Structures

struct  ble_tms_init_t
 Motion Service initialization structure. More...
 
struct  ble_tms_s
 Motion Service structure. More...
 

Macros

#define BLE_TMS_MAX_DATA_LEN   (GATT_MTU_SIZE_DEFAULT - 3)
 
#define BLE_UUID_TMS_SERVICE   0x0400
 

Typedefs

typedef void(* ble_tms_evt_handler_t )(ble_tms_t *p_tms, ble_tms_evt_type_t evt_type, uint8_t *p_data, uint16_t length)
 Motion Service event handler type.
 

Functions

uint32_t ble_tms_euler_set (ble_tms_t *p_tms, ble_tms_euler_t *p_data)
 Function for sending euler angle data. More...
 
uint32_t ble_tms_gravity_set (ble_tms_t *p_tms, ble_tms_gravity_t *p_data)
 Function for sending gravity vector data. More...
 
uint32_t ble_tms_heading_set (ble_tms_t *p_tms, ble_tms_heading_t *p_data)
 Function for sending compass heading data. More...
 
uint32_t ble_tms_init (ble_tms_t *p_wss, const ble_tms_init_t *p_tms_init)
 Function for initializing the Motion Service. More...
 
void ble_tms_on_ble_evt (ble_tms_t *p_wss, ble_evt_t *p_ble_evt)
 Function for handling the Motion Service's BLE events. More...
 
uint32_t ble_tms_orientation_set (ble_tms_t *p_tms, ble_tms_orientation_t *p_data)
 Function for sending orientation data. More...
 
uint32_t ble_tms_pedo_set (ble_tms_t *p_tms, ble_tms_pedo_t *p_data)
 Function for sending pedometer data. More...
 
uint32_t ble_tms_quat_set (ble_tms_t *p_tms, ble_tms_quat_t *p_data)
 Function for sending quaternion data. More...
 
uint32_t ble_tms_raw_set (ble_tms_t *p_tms, ble_tms_raw_t *p_data)
 Function for sending raw data. More...
 
uint32_t ble_tms_rot_mat_set (ble_tms_t *p_tms, ble_tms_rot_mat_t *p_data)
 Function for sending rotation matrix data. More...
 
uint32_t ble_tms_tap_set (ble_tms_t *p_tms, ble_tms_tap_t *p_data)
 Function for sending tap data. More...
 

Detailed Description

Thingy Motion Service implementation.

The Motion Service is a simple GATT-based service with TX and RX characteristics. Data received from the peer is passed to the application, and the data received from the application of this service is sent to the peer as Handle Value Notifications. This module demonstrates how to implement a custom GATT-based service and characteristics using the S110 SoftDevice. The service is used by the application to send and receive ASCII text strings to and from the peer.

Note
The application must propagate S110 SoftDevice events to the Motion Service module by calling the ble_tms_on_ble_evt() function from the ble_stack_handler callback.

Macro Definition Documentation

#define BLE_TMS_MAX_DATA_LEN   (GATT_MTU_SIZE_DEFAULT - 3)

Maximum length of data (in bytes) that can be transmitted to the peer by the Motion service module.

#define BLE_UUID_TMS_SERVICE   0x0400

The UUID of the Motion Service.

Function Documentation

uint32_t ble_tms_euler_set ( ble_tms_t p_tms,
ble_tms_euler_t *  p_data 
)

Function for sending euler angle data.

This function sends the input pitch, roll and yaw as an euler characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_gravity_set ( ble_tms_t p_tms,
ble_tms_gravity_t *  p_data 
)

Function for sending gravity vector data.

This function sends the input as a gravity vector characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_heading_set ( ble_tms_t p_tms,
ble_tms_heading_t *  p_data 
)

Function for sending compass heading data.

This function sends the input as a compass heading characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_init ( ble_tms_t p_wss,
const ble_tms_init_t p_tms_init 
)

Function for initializing the Motion Service.

Parameters
[out]p_wssMotion 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_tms_initInformation needed to initialize the service.
Return values
NRF_SUCCESSIf the service was successfully initialized. Otherwise, an error code is returned.
NRF_ERROR_NULLIf either of the pointers p_wss or p_tms_init is NULL.
void ble_tms_on_ble_evt ( ble_tms_t p_wss,
ble_evt_t *  p_ble_evt 
)

Function for handling the Motion Service's BLE events.

The Motion Service expects the application to call this function each time an event is received from the S110 SoftDevice. This function processes the event if it is relevant and calls the Motion Service event handler of the application if necessary.

Parameters
[in]p_wssMotion Service structure.
[in]p_ble_evtEvent received from the S110 SoftDevice.
uint32_t ble_tms_orientation_set ( ble_tms_t p_tms,
ble_tms_orientation_t *  p_data 
)

Function for sending orientation data.

This function sends the input orientation as an orientation characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the orientation data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_pedo_set ( ble_tms_t p_tms,
ble_tms_pedo_t *  p_data 
)

Function for sending pedometer data.

This function sends the input steps and time as an pedometer characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_quat_set ( ble_tms_t p_tms,
ble_tms_quat_t *  p_data 
)

Function for sending quaternion data.

This function sends the input quaternion as an quaternion characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the quaternion data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_raw_set ( ble_tms_t p_tms,
ble_tms_raw_t *  p_data 
)

Function for sending raw data.

This function sends the input as an raw characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_rot_mat_set ( ble_tms_t p_tms,
ble_tms_rot_mat_t *  p_data 
)

Function for sending rotation matrix data.

This function sends the input as a rotation matrix characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.
uint32_t ble_tms_tap_set ( ble_tms_t p_tms,
ble_tms_tap_t *  p_data 
)

Function for sending tap data.

This function sends the input tap as an tap characteristic notification to the peer.

Parameters
[in]p_tmsPointer to the Motion Service structure.
[in]p_dataPointer to the tap data.
Return values
NRF_SUCCESSIf the string was sent successfully. Otherwise, an error code is returned.