Bluetooth allows you to send and receive data to the Syrus using the TAIP
protocol in a secure manner. Other Bluetooth devices can ask, configure, and query the Syrus in a nearby area remotely.
Requisites
- Syrus 3G Bluetooth (S3GBT-2481)
- Device (Cellphone, Laptop) with Bluetooth Peripheral
- Bluetooth Low Energy 3.0 or superior
- Pegasus Gateway User
Example Code
You can find an example code in the following repository:
Cordova: https://github.com/dctdevelop/syrusbt-sample
Native Android: https://github.com/dctdevelop/syrusbt-android
Explanation
Bluetooth adds an additional layer of communication that’s parallel and independent of the Pegasus Gateway and the device’s RS-232 serial port.
Once communication is established, you may send commands in TAIP format (>QVR<) similar to how you would if you used serial communication. Any command can be sent via Bluetooth.
We use Bluetooth Low Energy (BLE) for the communication. Transmitting packets via ‘characteristics’, the packets cannot be greater than 63 bytes of information.
Similarly the reception of packets greater than 63 bytes is not supported. For data greater than 63 bytes it’s divided and sent in chunks, these chunks of data should be reassembled/interpreted by the endpoint.
The data is protected by hashed keyphrase that’s introduced the first time a connection is established between the host and the Syrus.
Note that Syrus does not respond to any command unless the keyphrase is presented.
The commands sent and their respected responses are asynchronous, even though Syrus responds from the first to the last command sent, the time between requests <–> response is variable. Commands with a long response such as (>QXAIM<) can take up to 3 seconds to respond.
Services and Characteristics
Syrus exposes one (1) service for the communication:
Service | UUID | Description |
---|---|---|
Communication | 00000000-dc70-0080-dc70-a07ba85ee4d6 | All the communication Protocol is going here |
and 2 characteristics:
Characteristic | UUID | Description |
---|---|---|
Communication | 00000000-dc70-0180-dc70-a07ba85ee4d6 | Allow send and receive data in TAIP Protocol |
Events | 00000000-dc70-0280-dc70- |
Allow to receive Events from the Syrus |
all the data is sent without confirmation to improve the performance.
Syrus Communication
Establishing connection
Syrus emit the name like Syrus 3GBT ABCDE
where:
ABCDE
is the last five digits of the syrus IMEI
Sending Data
Data must be sent over Communication Service and Communication Characteristic, our example code shows how to send a command using Javascript and cordova library BLE plugin central. you can read more about 8100 BLE PLUGIN CENTRAL
Data sent to the Syrus must be on array of bytes see the example above to convert the string to bytes.
Receiving Data
To receive data from Syrus you need to subscribe to the communication characteristic and expect changes, each package of data contains maximum 63 bytes, if the command received contains more than the limit the string will be spitted in n packages, and the user need to join/concatenate these packets.
The example shows how to send a command using Javascript and Cordova library BLE plugin central.
https://github.com/dctdevelop/syrusbt-sample
Keeping the Connection Alive
Syrus implements a protocol of disconnection, to prevent undesired connection over time. If a device connected to the Syrus does not send any commands within 2 minutes, the device will be disconnected.
To keep the connection alive, you can send a command in an interval of time, every 45 seconds for example, is a good interval to query the position of the device >QPV<.
Authorization
Syrus implements a protocol of security authentication. A Keycode
based on the IMEI of the device is used by default, this command must be the first thing sent over bluetooth.
If Syrus does not receive the keycode within 10 seconds, it will terminate the connection.
By default the keycode will be the last five digits of the Syrus IMEI, it’s recommended to change this code after installation/deployment of your device. You can change the keycode sending >SBIK{old_pin};{new_pin}<
To send the pin to Syrus after you get the code from Pegasus, you must send the code >SBIK{pin_code}<. If Syrus responds to the next command sent it means the authentication was done successfully.
function authenticatheWithSyrus(){ var text = ""; var possible = "abcdef0123456789"; for( var i=0; i < 8; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); var code = app.device.name.substr(app.device.name.length -5); code = text + md5(md5(code)+":"+text); var data = stringToBytes(">SBIK"+ code + "<"); ble.writeWithoutResponse(app.device.id, "00000000-dc70-0080-dc70-a07ba85ee4d6", "00000000-dc70-0180-dc70-a07ba85ee4d6", data, function(r){console.log(r)}, function(r){r}); }
Working with TAIP
The Syrus protocol TAIP allows you to interact remotely via bluetooth with other BLE compatible devices. Bluetooth as destination point (XADP) has the index 17, so you can send events via bluetooth adding P17 to a destination address DA. Once the bluetooth connection is available, you can receive events by doing a subscription to “Events” characteristic. The important commands to know are
- >QBIS< – query the bluetooth module firmware (1.03 is the latest, to update use >SBIFbtf_1.03< command)
- BIM – Bluetooth Interface mode, with this command you can configure how Syrus will work with external applications and configures the events storage mode. (Example if you want to have the Syrus be discoverable and connectable and discard events when the bluetooth destination is not available >SBIM10<)
- >SBICB< – command to clear the bluetooth’s destination point event buffer
For more information consult the device manual
Limitations
- Bluetooth Low Energy Protocol is limited to send/receive 63 bytes by package of data, this is a hardware limitation
- Syrus can connect to (1) one Android device and (1) one iOS device simultaneous, sometimes it’s possible connect to multiples android devices if the Bluetooth hardware is different in each device.
- Most Cellular devices and Desktops (Windows, Linux, Android, iOS, Mac, etc…) can connect at max to (6) six Syrus simultaneous, but it’s not recommended because it can generate lost 8100 packages and other security issues.
- Sometimes some packets can be lost if the Syrus is occupied with another process, Bluetooth layer is lower in priority than core processes.
- Sending multiple commands when Syrus is busy could produce glitches on the communication, so it’s recommended to send commands only when Syrus has returned a response.
Getting started with Syrus BT authentication
Use the following App to get an example on how to connect with Syrus BT Destination Point and download all data in the BT Buffer
Syrus Bluetooth FAQs
How many events does the bluetooth buffer hold?
The buffer can hold up to 30k events.
How can I establish MDT communication via Bluetooth?
Using the characteristic 00000000-dc70-0180-dc70-a07ba85ee4d6, you can subscribe to the MDT messages