Informational exchange protocol for SelfieBot

Table of contents

The structure of the package
Data transmitted from the software on Selfie Bot
Program management
Service commands set the name of the Bluetooth module
Data transmission from SelfieBot on an app

The structure of the package

Data is transferred byte packets. The package consists of four fields: a start-byte data field length, data field, a stop byte. The maximum packet size is limited to 255 bytes, ie, data size can not exceed 252 bytes.

Start-byte occupies 1 byte, and the volume is a sign of the beginning of the packet, the packet starts to be taken and collected only after receiving the start byte.

Sending length field takes 1 byte volume and sets the number of bytes of information in the packet.

The data field contains the information for the recipient (data commands or telemetry) and can take the volume from 1 to 255 bytes.

Stop byte occupies 1 byte and the volume is a sign of the end of the package, the package assembly on the fact of the specified length (in the packet length field) is checked stop-byte and a decision on the correctness of the received packet.

Table 1. Structure of an information package

Field Start byte Package length Data Stop-byte
Field size, value 1 1 1…252 1

Start-byte packet length field and the stop byte will organize the first protocol layer data packet.

The second protocol layer data packet determines the structure of the field data. The first data byte is a data identifier field and determines the recipient or source of the transmitted data. Thus, the final amount of the information data may not exceed 251 bytes.

Table 2. Structure of the data packet field

Field ID Data
Fields size, byte 1 1…251

Data transmitted from the software on Selfie Bot

Program management

Start-bytes = 3Ah.
The length of the parcel = 06h.
Stop byte = C5h.
The data field is composed of six bytes.

Package: 3A – 06 – D[0] – D[1] – … – D[5] – С5

The first data byte is the ID of standard commands, ID = D [0] = 01h.

The following are the contents of the data field D [1: 5] packets.

1) request command receiving generic telemetry

00 – 00 – 00 – 00 – 00

2) Program management horizontal actuator

01 – Data1 – XX – XX – XX

Data Size, bit Value, hex Default value., hex Value
Data1 8 0…FF 7F The angle of the horizontal position of the servo.
0 corresponds to 0 degrees, FFh – 180, 7Fh – 90.

The extreme values can be limited at the hardware level, in this case, the command will be accepted, but will be exposed to the permitted limit value, for example, instead of 180 degrees can be set to 175 or 170. The limit values can be monitored by telemetry returned.

3) Program management vertical actuator

02 – Data1 – XX – XX – XX

Data Size, bit Value, hex Default value., hex Value
Data1 8 0…FF 7F The angle of the vertical position of the servo.
0 corresponds to 0 degrees, FFh – 180, 7Fh – 90.

The extreme values can be limited at the hardware level, in this case, the command will be accepted, but will be exposed to the permitted limit value, for example, instead of 180 degrees can be set to 175 or 170. The limit values can be monitored by telemetry returned.

4) Program management horizontal and vertical actuators

03 – Data1 – Data2 – XX – XX

Data Size, bit Value, hex Default value, hex Value
Data1 8 0…FF 7F The angle of the horizontal position of the actuator.
0 corresponds to 0 degrees…, FFh – 180, 7Fh – 90.
Data2 8 0…FF 7F The angle of the vertical position of the actuator.
0 corresponds to 0 degrees, FFh – 180, 7Fh – 90.

The extreme values can be limited at the hardware level, in this case, the command will be accepted, but will be exposed to the permitted limit value, for example, instead of 180 degrees can be set to 175 or 170. The limit values can be monitored by telemetry returned.

Service commands set the name of the Bluetooth module

Start-bytes = 3Ah.

Length = 0Sh parcels.

Stop byte = S5h.

The data field consists of 13 bytes.

Пакет: 3A – 0С – D[0] – D[1] – … – D[12] – С5

The first data byte is the ID of a service command module with Bluetooth, ID = D [0] = 02h.

Data D [1:12] contain ASCII Bluetooth module name codes, which should be set after initializing the device. This name is accepted and recorded in the device memory. When transmitting zero dataset (D [1:12] = 0x00) the name of the previously recorded is erased from the device’s internal memory and will be set after initialization default name: SELFIEBOT-XX.

For the name of the module to be installed by default (SELFIEBOT-XX), will we have the following data set D [1:12]:

Byte number 1 2 3 4 5 6 7 8 9 10 11 12
ASCII code S E L F I E B O T - X X
Byte data DEC 83 69 76 70 73 69 66 79 84 45 88 88
Byte data HEX 53 45 4C 46 49 45 42 4F 54 2D 58 58

To record a new name for the Bluetooth module or erase the name of the memory to be transmitted service team 3 times. Upon successful acceptance and saving the new name of the module Bluetooth custom LED briefly (1 second) will change its color to blue when successfully erased – on white.

Data transmission from SelfieBot on an app

Start-bytes = 3Ah.

sending Length = 0 Ch.

Stop byte = S5h.

The data field consists of thirteen bytes.

Package: 3A – 0C – D [0] – D [1] – … – D [12] – C5

The first byte is a data telemetry identifier, ID = D [0] = F1h.

Here are the contents of the data field D [1:12] packages.

1) The package, formed in response to telemetry command request

Init – Status1 – Status2 – Angle1 – Angle2 – Vbat[0:7] – Vbat[8:15] – Vin[0:7] – Vin[8:15] – Light[0:7] – Light[8:15] – XX

Data Size, bit Value
Init 8 Byte result of an initialization
0 Establishing a connection with the Bluetooth module
0 Communication failure installation
1 Connected successfully
1 Bluetooth setup
0 Error in module setup
1 Module is ok
2 Bluetooth name
0 Module is initialized by default name: SELFIEBOT-XX
1 Module initialized title recorded earlier in the non-volatile memory device
3 Power check of servos
0 No power on servos
1 Servos power on
7:4
Status1 8 Byte status of a device
0 Power supply of servos
0 off
1 on
1 Automate on/off servo
0 off
1 on
2 External battery charger
0 Not found
1 found
3 External DC
0 off
1 on
4 USB supply
0 off
1 on
5 Supply of an external DC
0 Off
1 On
6 Usage of a movement sensor
0 Is not in use
1 In use
7 Value of a user button
0 off
1 on
Status2 8 Not in use
0
0
1
1
0
1
2
0
1
3
0
1
4
0
1
5
0
1
6
0
1
7
0
1
Angle1 8 0…FF Angle of horizontal servo 0, corresponds with 0 tilt

, FFh – 180, 7Fh – 90.

Angle1[град] = Angle1*(180/255).

Angle2 8 0…FF Angle of vertocal servo 0, corresponds with 0 tilt

, FFh – 180, 7Fh – 90.

Angle2[град] = Angle2*(180/255).

Vbat 16 0…3FF Value of a level of voltage on a battery

V[volt] = 5*[Vbat_2:Vbat_1].

Vin 16 0…3FF Value of a level of voltage from external DC

V[volt] = 5*[Vin_2:Vin_1].

Light 16 0…3FF Value of a level of voltage given by light sensor

V[вольт] = 5*[Light _2:Light _1].

ХХ Is not used