Transcript
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
Bluetooth API Protocol
Version
Date
1.0
2016/4/20
1.1
2016/7/12
1
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
1) The communica0on model ....................................................................3 1. Communica0on types and forms ..............................................3 2. Package types and structures ....................................................3 1.2.1. The overall structure........................................................4 1.2.2. The defini0on of the package fields.................................5 2) Detail descrip0on of the communica0on package ................................5 2.1.Single-byte command ..................................................................5 2.1.1. Data direc0on: APP -> BLE device ....................................6 2.1.2.Data direc0on: BLE device -> App.....................................6 2.2.Mul0-byte command ...................................................................7 2.2.1.Data direc0on:APP -> BLE device ......................................7 2.2.2.Data direc0on: BLE device -> App.....................................8 2.2.3.Data direc0on: all .............................................................8 2.3. Checksum ...................................................................................8 3) Data synchroniza0on .............................................................................9 4) Format of the data packages .................................................................9 4.1.Single-byte command ..................................................................9 4.1.1.Data direc0on: APP -> BLE Device ....................................9 4.1.2.Data direc0on: BLE device -> App...................................14 4.2.Mul0-byte command .................................................................15 4.2.1.Data direc0on: APP -> BLE device ...................................15 4.2.2.Data direc0on: BLE device -> APP ...................................20 4.2.3.Data Direc0on: BLE device -> App ..................................28 4.2.3.Data direc0on: BLE device -> App...................................29 4.2.4.Data direc0on: APP -> BLE device ...................................29 5. Supplement .........................................................................................30 5.1. Mul0-byte command ................................................................30 5.1.1 Data direc0on: APP -> BLE device ...................................30 5.2.1 Data Direc0on: BLE device -> App ..................................32 6. Examble: ..............................................................................................33
2
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
1)The communication model
APP
The BLE device
1.
Communication types and forms
2.
Package types and structures The package structure: [package header] [data] [checksum] [package trailer] [package header] 0x12 0x34 [package trailer] 0x43 0x21 [checksum] Data content accumulated in bytes [DATA] Defined in two types (For the detail, please see 1.2.2 Package field) 1、[DATA]==[TYPE] [LENGTH] [CMD] [DATA], The [TYPE] is 0x0A Example: [package header] [data package] [checksum] [package trailer] [TYPE] [LENGTH]
[CMD] [DATA]
3
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
0x0A [PAYLOAD] 2、[DATA]==[TYPE][CMD], [TYPE] is 0x0B Example: [package header] [data package] [checksum] [package trailer] [TYPE][CMD] 0x0B The [PAYLOAD] length range is 0-123 bytes. Examples: Package sample The single-byte command: PACKAGE=0X12+0X34+0x0B+CMD+checksum+0X43+0X21 The multi-byte command: PACKAGE=0X12+0X34+0x0A+CMD+LENGTH+DATA+checksum +0X43+0X21 1.2.1. The overall structure PACKAGE = 0x12 + 0X34 + data + checksum + 0X43 + 0X21
4
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
1.2.2. The definition of the package fields Name
Data
Description
TYPE
0X0A
The single-byte command
0X0B
The multi-byte command
CMD
8-bit data
The operation to be performed
LENGTH
8-bit data
The length of the data part, which is the next field follows the length field. The other fields such as checksum's length is not included.
DATA
depends
The data to be sent
checksum
8-bit data
the data package accumulated in bytes
2)Detail description of the communication package
2.1.Single-byte command The data package is 0X0A + [CMD]
5
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
2.1.1. Data direction: APP -> BLE device [CMD]
Description
0x01
Get the results of the step count
0x02
Get the value of the heart rate
0x03
Get the data of the ECG
0x04
Get the calories
0x05
Get the information of the sleep
0x07
Reset step count
0x08
Clear the distance
009
To unbind device
0x0E
Start/resume measurement
0x0F
Stop/pause measurement
2.1.2.Data direction: BLE device -> App [CMD]
Description
0x21
Start synchronization
0x22
Stop synchronization
0x23
Request device binding
6
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
2.2.Multi-byte command The data package is 0X0B + [CMD]+ LENGTH + DATA 2.2.1.Data direction:APP -> BLE device [CMD]
[LENGTH]
Data
0x11
Length of data
Paring information
0x12
Length of data
Datetime to be synchronized
0x13
Length of data
Response to binding request
0x14
Length of data
Timer
0x1b
Length of data
Second match
7
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
2.2.2.Data direction: BLE device -> App [CMD]
[LENGTH]
Data
0x31
8
Step count
0x32
8
Heart rate
0x33
8
PPG data
0x34
8
Calories
0x35
8
Sleep data
0x36
6
UV
0x37
2
Response to binding request
0x38
2
Response to unbinding request
2.2.3.Data direction: all [CODE]
Code meaning
0x2D
Command receiving succeeds
0x2E
Command receiving fails
2.3. Checksum Checksum is used to verify the completeness and validity of the data payload: 1. Accumulate each byte in [DATA] field 2. The final accumulated value is the checksum If the checksum calculated based on data field is same as the checksum received in the package, we think the package we receive is good, otherwise the package will be dropped.
8
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
3)Data synchronization
The BLE device starts to send data after receive the synchronization command from APP. The sequence for the synchronization package is: Start synchronization (with data type name) Data CRC End synchronization (with data type name)
4)Format of the data packages
4.1.Single-byte command 4.1.1.Data direction: APP -> BLE Device 4.1.1.1.Get step count 0x12
0x34
0X0A
0x01
c h e c k s 0x43 um
CMD
0x01
Description
Get step count
0x21
9
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.1.2.Get heart rate 0x12
0x34
0X0A
0x02
c h e c k s 0x43 um
CMD
0x02
Description
Get heart rate
0x21
4.1.1.3.Get PPG data 0x12
0x34
0X0A
0x03
c h e c k s 0x43 um
CMD
0x03
Description
Get PPG data
0x21
4.1.1.4.Get calories data 0x12
0x34
0X0A
0x04
c h e c k s 0x43 um
CMD
0x04
Description
Get calories data
0x21
10
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.1.5.Get sleep data 0x12
0x34
0X0A
0x05
c h e c k s 0x43 um
CMD
0x05
Description
Get sleep data
0x21
4.1.1.6.Get mood and fatigue (HRV) 0x12
0x34
0X0A
0x06
c h e c k s 0x43 um
0x21
CMD
0x06
Description
Get mood and fatigue (HRV)
4.1.1.7.Get fatigue 0x12
0x34
0X0A
0x07
c h e c k s 0x43 um
CMD
0x07
Description
Get fatigue
0x21
11
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.1.8.Clear distance 0x12
0x34
0X0A
0x08
c h e c k s 0x43 um
CMD
0x08
Description
Clear distance
0x21
4.1.1.9.Request to unbind 0x12
0x34
0X0A
0x09
c h e c k s 0x43 um
CMD
0x09
Description
Request to unbind
0x21
4.1.1.10.Get ECG 0x12
0x34
0X0A
0x0A
c h e c k s 0x43 um
CMD
0x0A
Description
Get ECG data
0x21
12
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.1.11.Get breath rate 0x12
0x34
0X0A
0x0B
c h e c k s 0x43 um
CMD
0x0B
Description
Get breath rate
0x21
4.1.1.12.Turn off the device 0x12
0x34
0X0A
0x0E
c h e c k s 0x43 um
0x21
CMD
0x0E
Description
Send command to turn off the device
4.1.1.13.Stop current measurement 0x12
0x34
0X0A
0x0F
c h e c k s 0x43 um
0x21
CMD
0x0F
Description
Stop current measurement
13
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.2.Data direction: BLE device -> App 4.1.2.1.Start data synchronization 0x12
0x34
0X0A
0x21
c h e c k s 0x43 um
0x21
CMD
0x21
Description
Start data synchronization
4.1.2.2.End data synchronization 0x12
0x34
0X0A
0x22
c h e c k s 0x43 um
0x21
CMD
0x22
Description
End data synchronization
4.1.2.3.Request to bind 0x12
0x34
0X0A
0x23
c h e c k s 0x43 um
0x21
CMD
0x23
Description
When pairing, if the device is not bound, then send this bind request
14
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.1.2.4.SOS 0x12
0x34
0X0A
0x24
c h e c k s 0x43 um
CMD
0x24
Description
Fire SOS request
0x21
4.2.Multi-byte command 4.2.1.Data direction: APP -> BLE device 4.2.1.1.Paring information 0x12
0x34 0X0B 0x11 LENGT D A T check 0x43 H A sum
0x21
CMD
0x11
LENGTH
4
DATA
User ID
Description
After the App logins, need to send the device the pairing information
15
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.1.2.Datatime synchronization 0x12
0x34 0X0B 0x12 L E N G D A T check 0x43 TH A sum
CMD
0x12
LENGTH
4
DATA
The timestamp
0x21
Description 4.2.1.3.Reponse to binding 0x12
0x34 0X0B 0x13 LENGT D A T check 0x43 H A sum
0x21
CMD
0x13
LENGTH
Length of data
DATA
[7:1]Bit reserved [0]: 1/0: succeed/fail
Description
Respond to device when received the binding request from device
16
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.1.4.Timer 0x12
0x34 0X0B 0x14 L E N G D A T check 0x43 TH A sum
0x21
CMD
0x14
LENGTH
6
DATA
[7:0]ID: 0-7 eight timers [8] type. 0: unrepeatable timer 1: repeatable timer [14:9]: reserved [15]: 0: timer is disabled 1: timer is enabled [47:16]: timestamp for timer, little-endian
Description
App sets timer for the BLE device
4.2.1.5.Health plan 0x12
0x34 0X0B 0x17 L E N G D A T check 0x43 TH A sum
CMD
0x17
LENGTH
1
0x21
17
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
DATA
The measurement interval for the health plan, the value is in minutes. E.g. 45 means measure once for each 45 minutes
Description
Set the measurement interval
4.2.1.8. MD5 checksum 0x12
0x34 0X0B 0x18 L E N G D A T check 0x43 TH A sum
0x21
CMD
0x18
LENGTH
9
DATA
1st byte: 1:The first 8 bytes of MD5 checksum 2:The last 8 bytes of MD5 checksum 2-9 bytes: The first/last 8 bytes of MD5 checksum, depends on the 1st byte of the data field
Description
18
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.1.9.Calibration of blood pressure 0x12
0x34 0X0B 0x19 L E N G D A T check 0x43 TH A sum
CMD
0x19
LENGTH
8
DATA
[31:0] SBP [63:31] DBP
0x21
Description 4.2.2.0. Load Protection program 0x12
0x34 0X0B 0x1a L E N G D A T check 0x43 TH A sum
CMD
0x1a
LENGTH
4
DATA
[31:0]: 1: default value
0x21
Description
19
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.2.Data direction: BLE device -> APP 4.2.2.1.Step count 0x12
0x34 0X0B 0x31 LENGT D A T check 0x43 H A sum
0x21
CMD
0x31
LENGTH
8
DATA
Timestamp and step count
Description
When app requests step count, return the value to app
4.2.2.2.Heart rate 0x12
0x34 0X0B 0x32 LENGT D A T check 0x43 H A sum
0x21
CMD
0x32
LENGTH
8
DATA
Timestamp and heart rate
Description
When app requests heart rate, return the value to app
20
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.2.3.PPG data 0x12
0x34 0X0B 0x33 LENGT D A T check 0x43 H A sum
0x21
CMD
0x33
LENGTH
N/A
DATA
PPG data
Description
When app requests PPG data, return the value to app
4.2.2.4.Calories 0x12
0x34 0X0B 0x34 LENGT D A T check 0x43 H A sum
0x21
CMD
0x34
LENGTH
8
DATA
Timestamp and calories
Description
When app requests calories, return the value to app
21
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.2.5.Sleep data 0x12
0x34 0X0B 0x35 LENGT D A T check 0x43 H A sum
0x21
CMD
0x35
LENGTH
8
DATA
Timestamp and sleep data
Description
When app requests sleep data, return the value to app
4.2.2.6.Get ECG data ALL DATA 4.2.2.7.Response to bind request 0x12
0x34 0X0B 0x37 LENGT D A T check 0x43 H A sum
CMD
0x37
LENGTH
1
DATA
[7:1] Reserved [0]: 1: Binding succeeded 0: Binding failed
0x21
22
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
Description
When the app sends bind request, the device needs to respond
4.2.2.8.Reponse to unbind request 0x12
0x34 0X0B 0x38 LENGT D A T check 0x43 H A sum
0x21
CMD
0x38
LENGTH
1
DATA
[7:1] Reserved [0]: 1: Unbinding succeeded 0: Unbinding failed
Description
When the app sends unbind request, the device needs to respond
4.2.2.9.Mood 0x12
0x34 0X0B 0x3B LENGT D A T check 0x43 H A sum
CMD
0x3B
LENGTH
1
DATA
0:Depression 1:Calm 2:Excitement 3、Invalid
0x21
23
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
Description 4.2.2.10.Fatigue 0x12
0x34 0X0B 0x3C LENGT D A T check 0x43 H A sum
CMD
0x3C
LENGTH
1
DATA
0:Normal 1:Tired 2:Very tired
0x21
Description 4.2.2.11.Breath rate 0x12
0x34 0X0B 0x3D LENGT D A T check 0x43 H A sum
CMD
0x3D
LENGTH
1
DATA
Breath rate
0x21
Description
24
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.2.12.Health plan 0x12 0x34 0 X 0 0 x 3 L E N G TYP DAT c h e c 0x43 0x21 B E TH E A ksum
CMD
0x3E
LENGTH
The length of type and data fields
TYPE
[7:0] 1: Step count 2: Heart rate 3: Calories 4: Sleep data 5: Mood 6: Fatigue 7: Breath rate 8: Blood pressure 9: ECG result
DATA
Timestamp and measurement data
Description
4.2.2.13. CRC for data synchronization 0x12
0x34 0X0B 0x3F LENGT D A T check 0x43 H A sum
0x21
25
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
CMD
0x3F
LENGTH
4
DATA
The accumulated value for the synchronized data
Description 4.2.2.14.Blood pressure 0x12
0x34 0X0B 0x41 LENGT D A T check 0x43 H A sum
CMD
0x41
LENGTH
6
DATA
[31:0] Timestamp [39:32] SBP [47:40] DBP
0x21
Description 4.2.2.15.ECG measurement result 0x12
0x34 0X0B 0x42 LENGT D A T check 0x43 H A sum
CMD
0x42
LENGTH
5
0x21
26
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
DATA
[31:0] Timestamp [39:32] 0: Normal 1: Abnormal
Description 4.2.2.16.Battery 0x12
0x34 0X0B 0x43 LENGT D A T check 0x43 H A sum
0x21
CMD
0x43
LENGTH
1
DATA
[7:0] 0-100 The percentage of the power level
Description 4.2.2.17.Sleep data 0x12
0x34 0X0B 0x44 LENGT D A T check 0x43 H A sum
CMD
0x44
LENGTH
Length of the DATA field
0x21
27
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
DATA
[7:0]: 1: Light sleep 2: Deep slepp 3: Wakeup When the first byte is 1 or 2, the rest part of the data is 8 bytes, the content is start time of the sleep + duration of the sleep. When the first byte is 3, the rest part of the data is 4 bytes, it's the timestamp of the wakeup.
Description 4.2.3.Data Direction: BLE device -> App 4.2.3.1.Obtain bluetooth MAC address 0x12
0x34 0X0A 0x50 check 0x43 sum
0x21
CMD
0x50
checksum
0x5A 0x00 0x00 0x00
Description
When the BLE device needs MAC address then send this command
28
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
4.2.3.Data direction: BLE device -> App 4.2.3.2.Already burned MAC 0x12
0x34 0X0A 0x51 check 0x43 sum
0x21
CMD
0x50
checksum
0x5B 0x00 0x00 0x00
Description 4.2.4.Data direction: APP -> BLE device 4.2.4.1.Set bluetooth MAC address 0x12
0x34 0x0B 0x10 LENGT D A T check 0x43 H A sum
CMD
0x10
LENGTH
6
DATA
MAC[0] MAC[1] MAC[2] MAC[3] MAC[4] MAC[5] MAC[6]
0x21
Description
29
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
5. Supplement
5.1. Multi-byte command 5.1.1 Data direction: APP -> BLE device 5.1.1.1 Second match 0x12
0x34 0X0B 0x1B L E N G D A T check 0x43 TH A sum
0x21
CMD
0x1B
LENGTH
1
DATA
[7:0]: 1:APP receive match success meesage 0:APP do not receive match success meesage
Description
Reduce the possibility to loss ble package.
30
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
5.1.1.2 APP Send Version 0x12
0x34 0X0B 0 x 1 L E N G D A T check 0x43 C TH A sum
0x21
CMD
0x1C
LENGTH
4
DATA
[31:24]: 0: Android App 1: IOS App [23:0]: APP Version Android Version Example: 160810; IOS Version Example: 111
Description
Send before match
5.1.1.3 LED Brightness Change 0x12
0x34 0X0B 0 x 1 L E N G D A T check 0x43 D TH A sum
CMD
0x61
LENGTH
2
0x21
31
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
DATA
[15]: 0:Day 1:Night [14:12]: Stand for three color. (0 stand for no selection): [14]:when 1, Selection is red light. [13]:when 1, Selection is green light. [12]:when 1, Selection is blue. [11:0]: intensity:1 to 10,ten level. [11:8]: value for red [7:4]: value for green [3:0]: value for blue
Description
5.2.1 Data Direction: BLE device -> App 5.2.1.1 LED Brightness Change respone 0x12
0x34 0X0B 0x45 L E N G D A T check 0x43 TH A sum
CMD
0x45
LENGTH
1
DATA
[7:0]: 1: change success others: error
0x21
Description
32
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
6. Examble:
About pair: 1) 2) 3) 4)
Paring information (0x11) Response to binding request (0x13) Second match(0x1b) Datetime to be synchronized(0x12)
About unpair: 1) Request to unbind(0x09) 2) Response to unbinding request (0x38)
33
WRMT
Bluetooth API Protocol
World Media &Technology Corp.
34