NORDIC Thingy:52 蓝牙 BLE 服务协议定义

Thingy: 52 SoC 蓝牙 BLE 服务协议定义

项目文件源于 Thingy_SDK_V2.1.0, 详细说明请见另一篇博客 "Nordic Thingy:52 SDK 安装及编译"


文件: ble_tss.c
#define BLE_UUID_TSS_CONFIG_CHAR        0x0501    /**< The UUID of the config Characteristic. */
#define BLE_UUID_TSS_SPKR_CHAR             0x0502    /**< The UUID of the speaker Characteristic. */
#define BLE_UUID_TSS_SPKR_STAT_CHAR   0x0503    /**< The UUID of the speaker Status Characteristic. */
#define BLE_UUID_TSS_MIC_CHAR               0x0504    /**< The UUID of the microphone Characteristic. */
// EF68xxxx-9B35-4933-9B10-52FFA9740042
#define TSS_BASE_UUID    {{0x42, 0x00, 0x74, 0xA9, 0xFF, 0x52, 0x10, 0x9B, 0x33, 0x49, 0x35, 0x9B, 0x00, 0x00, 0x68, 0xEF}} 

文件: ble_tms.c
#define BLE_UUID_TMS_CONFIG_CHAR          0x0401    /**< The UUID of the config Characteristic. */
#define BLE_UUID_TMS_TAP_CHAR                 0x0402    /**< The UUID of the tap Characteristic. */
#define BLE_UUID_TMS_ORIENTATION_CHAR 0x0403    /**< The UUID of the orientation Characteristic. */
#define BLE_UUID_TMS_QUATERNION_CHAR  0x0404    /**< The UUID of the quaternion Characteristic. */
#define BLE_UUID_TMS_PEDOMETER_CHAR    0x0405    /**< The UUID of the pedometer Characteristic. */
#define BLE_UUID_TMS_RAW_CHAR                 0x0406    /**< The UUID of the raw data Characteristic. */
#define BLE_UUID_TMS_EULER_CHAR               0x0407    /**< The UUID of the euler Characteristic. */
#define BLE_UUID_TMS_ROT_MAT_CHAR         0x0408    /**< The UUID of the rotation matrix Characteristic. */
#define BLE_UUID_TMS_HEADING_CHAR         0x0409    /**< The UUID of the compass heading Characteristic. */
#define BLE_UUID_TMS_GRAVITY_CHAR          0x040A    /**< The UUID of the gravity vector Characteristic. */
// EF68xxxx-9B35-4933-9B10-52FF-A974-0042
#define TSS_BASE_UUID    {{0x42, 0x00, 0x74, 0xA9, 0xFF, 0x52, 0x10, 0x9B, 0x33, 0x49, 0x35, 0x9B, 0x00, 0x00, 0x68, 0xEF}} 

文件: ble_tes.c
#define BLE_UUID_TES_TEMPERATURE_CHAR 0x0201    /**< The UUID of the temperature Characteristic. */
#define BLE_UUID_TES_PRESSURE_CHAR        0x0202    /**< The UUID of the pressure Characteristic. */
#define BLE_UUID_TES_HUMIDITY_CHAR        0x0203    /**< The UUID of the humidity Characteristic. */
#define BLE_UUID_TES_GAS_CHAR                  0x0204    /**< The UUID of the gas Characteristic. */
#define BLE_UUID_TES_COLOR_CHAR             0x0205    /**< The UUID of the gas Characteristic. */
#define BLE_UUID_TES_CONFIG_CHAR            0x0206    /**< The UUID of the config Characteristic. */
// EF68xxxx-9B35-4933-9B10-52FFA9740042
#define TSS_BASE_UUID    {{0x42, 0x00, 0x74, 0xA9, 0xFF, 0x52, 0x10, 0x9B, 0x33, 0x49, 0x35, 0x9B, 0x00, 0x00, 0x68, 0xEF}} 

文件: ble_tcs.c
#define BLE_UUID_TCS_DEVICE_NAME_CHAR   0x0101    /**< The UUID of the device name Characteristic. */
#define BLE_UUID_TCS_ADV_PARAMS_CHAR    0x0102    /**< The UUID of the advertising parameters Characteristic. */
#define BLE_UUID_TCS_APPEARANCE_CHAR      0x0103    /**< The UUID of the appearance Characteristic. */
#define BLE_UUID_TCS_CONN_PARAM_CHAR    0x0104    /**< The UUID of the connection parameters Characteristic. */
#define BLE_UUID_TCS_BEACON_PARAM_CHAR  0x0105    /**< The UUID of the beacon Characteristic. */
#define BLE_UUID_TCS_CLOUD_PARAM_CHAR   0x0106    /**< The UUID of the cloud token Characteristic. */
#define BLE_UUID_TCS_FW_VERSION_CHAR        0x0107    /**< The UUID of the FW version Characteristic. */
#define BLE_UUID_TCS_MTU_CHAR                      0x0108    /**< The UUID of the MTU Characteristic. */
// EF68xxxx-9B35-4933-9B10-52FFA9740042

#define TSS_BASE_UUID    {{0x42, 0x00, 0x74, 0xA9, 0xFF, 0x52, 0x10, 0x9B, 0x33, 0x49, 0x35, 0x9B, 0x00, 0x00, 0x68, 0xEF}} 

Thingy: 52 Android App 蓝牙 BLE 服务协议定义

文件:app\thingylib\java\no.nordicsemi.android.thingylib\utils\ThingyUtils.java

源自 Nordic Thingy 52, Android App 源码, 参见文章 "Nordic Thingy:52 Android App 源码及APK"

public static final UUID THINGY_BASE_UUID                                                   = new UUID(0xEF6801009B354933L, 0x9B1052FFA9740042L);

    public static final UUID THINGY_CONFIGURATION_SERVICE                                       = new UUID(0xEF6801009B354933L, 0x9B1052FFA9740042L);
    public static final UUID DEVICE_NAME_CHARACTERISTIC_UUID                                    = new UUID(0xEF6801019B354933L, 0x9B1052FFA9740042L);
    public static final UUID ADVERTISING_PARAM_CHARACTERISTIC_UUID                              = new UUID(0xEF6801029B354933L, 0x9B1052FFA9740042L);
    public static final UUID APPEARANCE_CHARACTERISTIC_UUID                                     = new UUID(0xEF6801039B354933L, 0x9B1052FFA9740042L);
    public static final UUID CONNECTION_PARAM_CHARACTERISTIC_UUID                               = new UUID(0xEF6801049B354933L, 0x9B1052FFA9740042L);
    public static final UUID EDDYSTONE_URL_CHARACTERISTIC_UUID                                  = new UUID(0xEF6801059B354933L, 0x9B1052FFA9740042L);
    public static final UUID CLOUD_TOKEN_CHARACTERISTIC_UUID                                    = new UUID(0xEF6801069B354933L, 0x9B1052FFA9740042L);
    public static final UUID FIRMWARE_VERSION_CHARACERISTIC_UUID                                = new UUID(0xEF6801079B354933L, 0x9B1052FFA9740042L);


    public static final UUID BATTERY_SERVICE                                                    = UUID.fromString("0000180F-0000-1000-8000-00805f9b34fb");
    public static final UUID BATTERY_SERVICE_CHARACTERISTIC                                     = UUID.fromString("00002A19-0000-1000-8000-00805f9b34fb");


    public static final UUID THINGY_ENVIRONMENTAL_SERVICE                                       = new UUID(0xEF6802009B354933L, 0x9B1052FFA9740042L);
    public static final UUID TEMPERATURE_CHARACTERISTIC                                         = new UUID(0xEF6802019B354933L, 0x9B1052FFA9740042L);
    public static final UUID PRESSURE_CHARACTERISTIC                                            = new UUID(0xEF6802029B354933L, 0x9B1052FFA9740042L);
    public static final UUID HUMIDITY_CHARACTERISTIC                                            = new UUID(0xEF6802039B354933L, 0x9B1052FFA9740042L);
    public static final UUID AIR_QUALITY_CHARACTERISTIC                                         = new UUID(0xEF6802049B354933L, 0x9B1052FFA9740042L);
    public static final UUID COLOR_CHARACTERISTIC                                               = new UUID(0xEF6802059B354933L, 0x9B1052FFA9740042L);
    public static final UUID CONFIGURATION_CHARACTERISTIC                                       = new UUID(0xEF6802069B354933L, 0x9B1052FFA9740042L);


    public static final UUID THINGY_UI_SERVICE                                                  = new UUID(0xEF6803009B354933L, 0x9B1052FFA9740042L);
    public static final UUID LED_CHARACTERISTIC                                                 = new UUID(0xEF6803019B354933L, 0x9B1052FFA9740042L);
    public static final UUID BUTTON_CHARACTERISTIC                                              = new UUID(0xEF6803029B354933L, 0x9B1052FFA9740042L);


    public static final UUID THINGY_MOTION_SERVICE                                              = new UUID(0xEF6804009B354933L, 0x9B1052FFA9740042L);
    public static final UUID THINGY_MOTION_CONFIGURATION_CHARACTERISTIC                         = new UUID(0xEF6804019B354933L, 0x9B1052FFA9740042L);
    public static final UUID TAP_CHARACTERISTIC                                                 = new UUID(0xEF6804029B354933L, 0x9B1052FFA9740042L);
    public static final UUID ORIENTATION_CHARACTERISTIC                                         = new UUID(0xEF6804039B354933L, 0x9B1052FFA9740042L);
    public static final UUID QUATERNION_CHARACTERISTIC                                          = new UUID(0xEF6804049B354933L, 0x9B1052FFA9740042L);
    public static final UUID PEDOMETER_CHARACTERISTIC                                           = new UUID(0xEF6804059B354933L, 0x9B1052FFA9740042L);
    public static final UUID RAW_DATA_CHARACTERISTIC                                            = new UUID(0xEF6804069B354933L, 0x9B1052FFA9740042L);
    public static final UUID EULER_CHARACTERISTIC                                               = new UUID(0xEF6804079B354933L, 0x9B1052FFA9740042L);
    public static final UUID ROTATION_MATRIX_CHARACTERISTIC                                     = new UUID(0xEF6804089B354933L, 0x9B1052FFA9740042L);
    public static final UUID HEADING_CHARACTERISTIC                                             = new UUID(0xEF6804099B354933L, 0x9B1052FFA9740042L);
    public static final UUID GRAVITY_VECTOR_CHARACTERISTIC                                      = new UUID(0xEF68040A9B354933L, 0x9B1052FFA9740042L);


    public static final UUID THINGY_SOUND_SERVICE                                               = new UUID(0xEF6805009B354933L, 0x9B1052FFA9740042L);
    public static final UUID THINGY_SOUND_CONFIG_CHARACTERISTIC                                 = new UUID(0xEF6805019B354933L, 0x9B1052FFA9740042L);
    public static final UUID THINGY_SPEAKER_DATA_CHARACTERISTIC                                 = new UUID(0xEF6805029B354933L, 0x9B1052FFA9740042L);
    public static final UUID THINGY_SPEAKER_STATUS_CHARACTERISTIC                               = new UUID(0xEF6805039B354933L, 0x9B1052FFA9740042L);
    public static final UUID THINGY_MICROPHONE_CHARACTERISTIC                                   = new UUID(0xEF6805049B354933L, 0x9B1052FFA9740042L);


    public static final UUID CLIENT_CHARACTERISTIC_CONFIGURATOIN_DESCRIPTOR                     = new UUID(0x0000290200001000L, 0x800000805f9B34FBL);


    public final static ParcelUuid PARCEL_SECURE_DFU_SERVICE                                    = ParcelUuid.fromString("0000FE59-0000-1000-8000-00805F9B34FB");
    public final static UUID SECURE_DFU_SERVICE                                                 = UUID.fromString("0000FE59-0000-1000-8000-00805F9B34FB");
    public static final UUID THINGY_BUTTONLESS_DFU_SERVICE                                      = new UUID(0x8E400001F3154F60l, 0x9FB8838830DAEA50L);
    public static final UUID DFU_DEFAULT_CONTROL_POINT_CHARACTERISTIC                           = new UUID(0x8EC90001F3154F60l, 0x9FB8838830DAEA50L);
    public static final UUID DFU_CONTROL_POINT_CHARACTERISTIC_WITHOUT_BOND_SHARING              = new UUID(0x8EC90003F3154F60l, 0x9FB8838830DAEA50L);
NORDIC Thingy 52 原文手册说明

BLE services

This section focuses on the custom services used in the Thingy firmware together with their configuration parameters.

Thingy configuration service

The Thingy configuration service is responsible for handling all general configuration parameters that are not related to a particular module.

Name UUID Type Data Description
Base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042      
Thingy configuration service 0100      
Device name characteristic 0101 Write/Read max 10 bytes Device name as ASCII string.
Advertising param characteristic 0102 Write/Read 3 bytes Advertising parameters (in units):
  • uint16_t - Adv interval in ms (unit 0.625 ms).
    • min 32 -> 20 ms
    • max 8000 -> 5 s
  • uint8_t - Adv timeout in s (unit 1 s).
    • min 0 -> 0 s
    • max 180 s -> 3 min
Connection param characteristic 0104 Write/Read 8 bytes Connection parameters:
  • uint16_t - Min connection interval (unit 1.25 ms).
    • min 6 -> 7.5 ms
    • max 3200 -> 4 s
  • uint16_t - Max connection interval (unit 1.25 ms).
    • Same as above.
  • uint16_t - Slave latency (number of connection events).
    • Range 0-499
  • uint16_t - Supervision timeout (unit 10 ms).

    • Min 10 -> 100 ms
    • Max 3200 -> 32 s

    The following constraint applies: conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval that corresponds to the following Bluetooth Spec requirement: The Supervision_Timeout in milliseconds must be larger than (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.

Eddystone URL 0105 Write/Read 3-17 bytes Eddystone URL. Data format:
Cloud token 0106 Write/Read max 250 bytes Cloud token to be used for identification against cloud services.
FW version 0107 Read 3 bytes
  • uint8_t - major
  • uint8_t - minor
  • uint8_t - patch
MTU request 0108 Write/Read req 3 bytes MTU request. Not retained.
  • uint8_t - Peripheral exchange request
    • 0x00 - Peripheral does not send an MTU exchange request. (Default behavior)
    • 0x01 - Peripheral sends an MTU exchange request, when written to 0x01.
  • uint16_t - MTU size requested (23 - 276 bytes).

Environment service

The environment module is responsible for reading the temperature, pressure, humidity, air quality/gas, and light intensity/color sensors, as well as for sending data and configuration. It is running on top of the environment BLE service (ble_tes), the environment sensor drivers, and the environment flash storage with base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042. The configuration is stored in flash. To turn on sensor reading, enable notifications from the desired characteristic by writing 0x0001 to the Client Characteristic Configuration Descriptor (CCCD) for that characteristic.

Name UUID Type Data Description
Base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042      
Weather station service 0200      
Temperature characteristic 0201 Notify 2 bytes Temperature in Celsius
  • int8_t - integer
  • uint8_t - decimal
Pressure characteristic 0202 Notify 5 bytes Pressure in hPa
  • int32_t - integer
  • uint8_t - decimal
Humidity characteristic 0203 Notify 1 bytes Relative humidity in %
  • uint8_t - RH
Gas (Air quality) characteristic 0204 Notify 4 bytes
  • uint16_t - eCO2 ppm
  • uint16_t - TVOC ppb
Color characteristic 0205 Notify 8 bytes
  • uint16_t - Red
  • uint16_t - Green
  • uint16_t - Blue
  • uint16_t - Clear
Configuration characteristic 0206 Write/Read 12 bytes
  • uint16_t - Temperature interval in ms (100 ms - 60 s).
  • uint16_t - Pressure interval in ms (50 ms - 60 s).
  • uint16_t - Humidity interval in ms (100 ms - 60 s).
  • uint16_t - Color interval in ms (200 ms - 60 s).
  • uint8_t - Gas mode
    • 1 = 1 s interval
    • 2 = 10 s interval
    • 3 = 60 s interval
  • Color sensor LED calibration:
    • uint8_t - Red intensity [0 - 255]
    • uint8_t - Green intensity [0 - 255]
    • uint8_t - Blue intensity [0 - 255]

User interface service

The UI module handles the onboard LEDs, buttons, and other potential UI components like a quadrature decoder, touchscreen etc. The UI module runs on top of the UI BLE Service (ble_uis), the LED and button drivers, and the UI flash storage with base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042. This module enables RGB LED value setting and button event notifications via BLE. Button notification is enabled by writing 0x0001 to the CCCD of the button characteristic.

Name UUID Type Data Description
Base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042      
UI service 0300      
LED characteristic 0301 Write req/Read Max 5 bytes RGB Value:
  • uint8_t - Mode (retained for BLE connected and disconnected):
    • 0 = Off
    • 1 = Constant
    • 2 = Breathe
    • 3 = One Shot
Constant mode (retained for BLE connected):
  • uint8_t - R intensity (0 - 255)
  • uint8_t - G intensity (0 - 255)
  • uint8_t - B intensity (0 - 255)
Breathe mode (retained for BLE connected):
  • uint8_t - color:
    • 0x01 - RED
    • 0x02 - GREEN
    • 0x03 - YELLOW
    • 0x04 - BLUE
    • 0x05 - PURPLE
    • 0x06 - CYAN
    • 0x07 - WHITE
  • uint8_t - intensity (1-100) [%]
  • uint16_t - delay [ms] (50 ms - 10 s)
One shot mode (retained for BLE connected):
  • uint8_t - color:
    • 0x01 - RED
    • 0x02 - GREEN
    • 0x03 - YELLOW
    • 0x04 - BLUE
    • 0x05 - PURPLE
    • 0x06 - CYAN
    • 0x07 - WHITE
  • uint8_t - intensity (1-100) [%]
Default connected behavior:
  • Mode: Breathe
  • Color: CYAN
  • Intensity: 20%
  • Delay: 3500 ms
Button characteristic 0302 Notify 1 byte Boolean button state:
  • 0: Button released
  • 1: Button pressed
EXT pin characteristic 0303 Write req/Read 4 bytes

External pin control. Range 0 - 255. 0 is off, 255 is on.

PWM is not implemented. So either 0 or 255.

  • uint8_t - MOS_1
  • uint8_t - MOS_2
  • uint8_t - MOS_3
  • uint8_t - MOS_4

Motion service

The motion module is responsible for reading the 9-axis motion sensor and the low power accelerometer, as well as for sending the data and flash storage of the configuration parameters for this module. It is running on top of the motion BLE service (ble_tms) with base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042. The configuration is stored in flash memory. To turn on sensor reading, enable notifications from the desired characteristic by writing 0x0001 to the Client Characteristic Configuration Descriptor (CCCD) for that characteristic.

Name UUID Type Data Description
Base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042      
Thingy motion service 0400      
Config characteristic 0401 Write/Read 9 bytes Motion configuration:
  • uint16_t - Step counter interval in ms (100 ms - 5 s).
  • uint16_t - Temperature compensation interval in ms (100 ms - 5 s).
  • uint16_t - Magnetometer compensation interval in ms (100 ms - 1 s).
  • uint16_t - Motion processing unit frequency in Hz (5 - 200 Hz).
  • uint8_t - Wake-on-motion
    • 0x00 = Off
    • 0x01 = On
Tap characteristic 0402 Notify 2 bytes Direction and count of taps:
  • uint8_t - Direction:
    • 0x01 = TAP_X_UP
    • 0x02 = TAP_X_DOWN
    • 0x03 = TAP_Y_UP
    • 0x04 = TAP_Y_DOWN
    • 0x05 = TAP_Z_UP
    • 0x06 = TAP_Z_DOWN
  • uint8_t - Count
    • Number of taps in the given direction
Orientation characteristic 0403 Notify 1 byte
  • uint8_t - Orientation
    • 0x00 = Portrait
    • 0x01 = Landscape
    • 0x02 = Reverse portrait
    • 0x03 = Reverse landscape
Quaternion characteristic 0404 Notify 16 bytes Attitude represented with quaternions (2Q30 fixed point):
  • int32_t - w
  • int32_t - x
  • int32_t - y
  • int32_t - z
Step counter characteristic 0405 Notify 8 bytes Step counter:
  • uint32_t - Steps
  • uint32_t - Time [ms]
Raw data characteristic 0406 Notify 18 bytes Motion sensor raw data:
  • Accelerometer
    • int16_t - x [G] (6Q10 fixed point)
    • int16_t - y [G] (6Q10 fixed point)
    • int16_t - z [G] (6Q10 fixed point)
  • Gyroscope
    • int16_t - x [deg/s] (11Q5 fixed point)
    • int16_t - y [deg/s] (11Q5 fixed point)
    • int16_t - z [deg/s] (11Q5 fixed point)
  • Compass
    • int16_t - x [µT] (12Q4 fixed point)
    • int16_t - y [µT] (12Q4 fixed point)
    • int16_t - z [µT] (12Q4 fixed point)
Euler characteristic 0407 Notify 12 bytes Attitude represented in Euler angles (16Q16 fixed point)
  • int32_t - roll [degrees]
  • int32_t - pitch [degrees]
  • int32_t - yaw [degrees]
Rotation matrix char 0408 Notify 18 bytes Attitude in rotation matrix (2Q14 fixed point)
  • int16_t [9] - 3 x 3 matrix
Heading characteristic 0409 Notify 4 bytes Heading (16Q16 fixed point)
  • int32_t - Heading [degrees]
Gravity vector 040A Notify 12 bytes Attitude represented by a gravity vector:
  • float - x
  • float - y
  • float - z

Sound service

The sound module is responsible for handling both the speaker and the microphone. The sound module is built on top of the sound BLE service (ble_tss) with base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042. The configuration is stored in flash.

Name UUID Type Data Description
Base UUID EF68xxxx-9B35-4933-9B10-52FFA9740042      
Thingy sound service 0500      
Config characteristic 0501 Write/Read 2 bytes Sound configuration
  • uint8_t - Speaker mode:
    • 0x01 - Frequency and duration.
    • 0x02 - 8-bit PCM
    • 0x03 - Sample
  • uint8_t - Microphone mode
    • 0x01 - ADPCM
    • 0x02 - SPL
Speaker data characteristic 0502 Write without resp Max 273 bytes In frequency mode:
  • uint16_t - Frequency in Hz (0 - stop forever).
  • uint16_t - Duration in ms (0 = forever).
  • uint8_t - Volume in % (0-100).
In PCM mode:
  • uint8_t [20 - 273] 8-bit PCM samples
In sample mode:
  • uint8_t - sample ID (0x00 - 0x08)
    • 0 Collect_Point_00.wav
    • 1 Collect_Point_01.wav
    • 2 Explosion_02.wav
    • 3 Explosion_04.wav
    • 4 Hit_00.wav
    • 5 Pickup_01.wav
    • 6 Pickup_03.wav
    • 7 Shoot_00.wav
    • 8 Shoot_01.wav
Speaker status characteristic 0503 Notify 1 byte Speaker status
  • uint8_t - 0x00 - Finished
  • uint8_t - 0x01 - Buffer warning
  • uint8_t - 0x02 - Buffer ready
  • uint8_t - 0x10 - Packet disregarded
  • uint8_t - 0x11 - Invalid command
Microphone characteristic 0504 Notify Max 273 bytes ADCPM mode
  • ADPCM frame

Battery service

This module is responsible for handling battery level information.

Name UUID Type Data Description
UUID 180F Notify/Read 1 byte
  • uint8_t State of charge [%] (0-100)
Uses a lookup table to convert from battery voltage to state of charge (SoC). Due to the ADC configuration and battery model, certain percentage values are skipped. Will only update/notify if there is a change in remaining battery level.

DFU service

This module is responsible for running Device Firmware Updates on Thingy.

Name UUID Type Data Description
Secure DFU Service FE59      
Base UUID 0000xxxx-0000-1000-8000-00805f9b34fb      
DFU Control Point characteristic 8EC90001-F315-4F60-9FB8-838830DAEA50 Notify/Write 1 byte

Steps to put Thingy into Buttonless DFU mode:

  • Enable notifications for the DFU Control point characteristic
  • Write 0x01 to the characteristic



猜你喜欢

转载自blog.csdn.net/weixin_42396877/article/details/80861601