Bluetooth Definitions

Introduction

this folder contains the definitions of the bluetooth packets and UUID's used in the project. this folder is synced with the definitions on the HALO, so any changes made here should be reflected on the HALO.

TODO make this a submodule

this is split into 4 parts, with a 5th "ble_deffs.h" file that includes all the other files.

  • ftms_deffs, which contains the definitions for the Fitness Machine Service
    • more info on the Fitness Machine Service can be found here
  • indoor_bike, which contains the definitions for the Indoor Bike Notification of the Fitness Machine Service.
  • eftms_deffs, which contains the definitions for the (Extended / Energym) Fitness Machine Service, which is a custom service adding synchronisation for
    • bike number
    • FTP
  • ota_deffs, which contains the definitions for the OTA service another custom service for updating the firmware over the air.
  • ble_deffs, which includes all the other files.

Usage

the general layout of the files is as follows:

  • a collection of UUID's as #defines, usualy with the naming scheme

[MODULE]UUID[CHAR / SERVICE]

e.g.

#define FTMS_UUID_SERVICE 0x1826
  • a collection of typedef structs and enums for the packets used in the service.

these typedefs and structs are all prefixed with the name of the service they are used in, and all defined with packed to ensure they are the correct size.

e.g.

typedef enum __attribute__((__packed__))
{
    FTMS_CONTROL_RESERVED = 0x00,
    FTMS_CONTROL_STOP = 0x01,
    FTMS_CONTROL_PAUSE = 0x02
} ftms_control_t;

Notes

  • the UUID's are defined as 16 bit values, the macro 'BLE_UUID16_DECLARE' converts them to the correct format for the BLE stack.

FTMS Definitions

FTMS Services

FTMS Service

the core FTMS service

#define FTMS_UUID_SERVICE 0x1826

FTMS Characteristics

FTMS Feature

the feature characteristic of the FTMS service must be readable, and is read as a bitfield

#define FTMS_UUID_CHAR_FEATURE 0x2ACC

FTMS Control Point

the control point characteristic of the FTMS service must be writeable, and is written as a 'ftms_control_point_request_t' struct

#define FTMS_UUID_CHAR_CONTROL_POINT 0x2AD9

FTMS Status

the status characteristic of the FTMS service must be readable, and is read as a 'ftms_status_t' struct

#define FTMS_UUID_CHAR_STATUS 0x2ADA

FTMS Supported Features

these uuids are not read or written, but them being defined in the GATT table tells the connecting device that the given feature is supported.

currently we only support 'FTMS_UUID_SUPPORTED_RESISTANCE_LEVEL_RANGE'

// FTMS Supported Features UUIDs
#define FTMS_UUID_SUPPORTED_INCLINATION_RANGE 0x2AD5
#define FTMS_UUID_SUPPORTED_RESISTANCE_LEVEL_RANGE 0x2AD6
#define FTMS_UUID_SUPPORTED_POWER_RANGE 0x2AD8
#define FTMS_UUID_SUPPORTED_HEART_RATE_RANGE 0x2AD7
#define FTMS_UUID_SUPPORTED_SPEED_RANGE 0x2AD4

FTMS Packet definitions

FTMS Control Point Op Codes

the list of opcodes for the control point characteristic packed into a single byte

// FTMS Control Point Op Codes
typedef enum __attribute__((__packed__))
{
    FTMS_OP_CODE_REQUEST_CONTROL = 0x00,
    FTMS_OP_CODE_RESET = 0x01,
    FTMS_OP_CODE_SET_TARGET_SPEED = 0x02,
    FTMS_OP_CODE_SET_TARGET_INCLINE = 0x03,
    FTMS_OP_CODE_SET_TARGET_RESISTANCE_LEVEL = 0x04,
    FTMS_OP_CODE_SET_TARGET_POWER = 0x05,
    FTMS_OP_CODE_SET_TARGET_HEART_RATE = 0x06,
    FTMS_OP_CODE_START_RESUME = 0x07,
    FTMS_OP_CODE_STOP_PAUSE = 0x08,
    FTMS_OP_CODE_SET_TARGETED_EXPENDED_ENERGY = 0x09,
    FTMS_OP_CODE_SET_TARGETED_NUMBER_OF_STEPS = 0x0A,
    FTMS_OP_CODE_SET_TARGETED_NUMBER_OF_STRIDES = 0x0B,
    FTMS_OP_CODE_SET_TARGETED_DISTANCE = 0x0C,
    FTMS_OP_CODE_SET_TARGETED_TIME_DURATION = 0x0D,
    FTMS_OP_CODE_SET_TARGETED_TIME_IN_TWO_HEART_RATE_ZONES = 0x0E,
    FTMS_OP_CODE_SET_TARGETED_TIME_IN_THREE_HEART_RATE_ZONES = 0x0F,
    FTMS_OP_CODE_SET_TARGETED_TIME_IN_FIVE_HEART_RATE_ZONES = 0x10,
    FTMS_OP_CODE_SET_INDOOR_BIKE_SIMULATION_PARAMETERS = 0x11,
    FTMS_OP_CODE_SET_WHEEL_CIRCUMFERENCE = 0x12,
    FTMS_OP_CODE_SPIN_DOWN_CONTROL = 0x13,
    FTMS_OP_CODE_SET_TARGETED_CADENCE = 0x14,
    FTMS_OP_CODE_RESPONSE_CODE = 0x80
} ftms_control_point_op_code_t;

FTMS Control Point Response Codes

the list of response codes for the control point characteristic packed into a single byte

// FTMS Control Point Response Codes
typedef enum __attribute__((__packed__))
{
    FTMS_RESPONSE_CODE_SUCCESS = 0x01,
    FTMS_RESPONSE_CODE_OP_NOT_SUPPORTED = 0x02,
    FTMS_RESPONSE_CODE_INVALID_PARAMETER = 0x03,
    FTMS_RESPONSE_CODE_OPERATION_FAILED = 0x04,
    FTMS_RESPONSE_CODE_CONTROL_NOT_PERMITTED = 0x05
} ftms_control_point_response_code_t;