| Nordic Thingy:52 v2.0.0

Data Structures | Macros | Typedefs | Functions
Thingy Motion Service
BLE services

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_CONFIG_COMP_INT_MAX 1000
| Maximum compass compensation interval [ms].
#define | BLE_TMS_CONFIG_COMP_INT_MIN 100
| Minimum compass compensation interval [ms].
#define | BLE_TMS_CONFIG_MPUF_MAX 200
| Maximum motion processing frequency [Hz].
#define | BLE_TMS_CONFIG_MPUF_MIN 5
| Minimum motion processing frequency [Hz]. (4 Hz minimum to mpu_set_sample_rate())
#define | BLE_TMS_CONFIG_PEDO_INT_MAX 5000
| Maximum pedometer interval [ms].
#define | BLE_TMS_CONFIG_PEDO_INT_MIN 100
| Minimum pedometer interval [ms].
#define | BLE_TMS_CONFIG_TEMP_INT_MAX 5000
| Maximum temperature compensation interval [ms].
#define | BLE_TMS_CONFIG_TEMP_INT_MIN 100
| Minimum temperature compensation interval [ms].
#define | BLE_TMS_CONFIG_WOM_MAX 1
| Wake on motion off.
#define | BLE_TMS_CONFIG_WOM_MIN 0
| Wake on motion on.
#define | BLE_TMS_MAX_DATA_LEN (BLE_GATT_ATT_MTU_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

## ◆ BLE_TMS_MAX_DATA_LEN

#define BLE_TMS_MAX_DATA_LEN (BLE_GATT_ATT_MTU_DEFAULT - 3)

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

## ◆ BLE_UUID_TMS_SERVICE

#define BLE_UUID_TMS_SERVICE 0x0400

The UUID of the Motion Service.

## Function Documentation

## ◆ ble_tms_euler_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_gravity_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_heading_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_init()

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_wss | Motion 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_init | Information needed to initialize the service.

Return values

  NRF_SUCCESS | If the service was successfully initialized. Otherwise, an error code is returned.
  NRF_ERROR_NULL | If either of the pointers p_wss or p_tms_init is NULL.

## ◆ ble_tms_on_ble_evt()

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_wss | Motion Service structure.
  [in] | p_ble_evt | Event received from the S110 SoftDevice.

## ◆ ble_tms_orientation_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the orientation data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_pedo_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_quat_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the quaternion data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_raw_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_rot_mat_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.

## ◆ ble_tms_tap_set()

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_tms | Pointer to the Motion Service structure.
  [in] | p_data | Pointer to the tap data.

Return values

  NRF_SUCCESS | If the string was sent successfully. Otherwise, an error code is returned.