Configuration

You will find information about parameter configuration by Bluetooth here

There is a mobile application presently only available for Android being developed, which supports updating of parameters using the on board Bluetooth 5 interface.

When you power on the device, it presents itself with the name P2PSRV1

The device runs a Custom P2P server Bluetooth profile code which exposes a few characteristics to be written to or read from to interact with the device.

Here are the Bluetooth interface details you need to be able to read and write from the device,

Service UUID : 0000fe40-cc7a-482a-984a-7f2ed5b3e58f

TX Characteristic : 0000fe41-8e22-4541-9d4c-21edae82ed19

Rx Characteristic : 0000fe42-8e22-4541-9d4c-21edae82ed19

Transmission and reception is from phones perspective

List of parameters supported :

Index

Command Name

Description

Size [Bytes]

0

Band

Network band to be selected, Best to leave default

30

1

Working Mode

Devices location sending mode HTTP / TCP / SMS

5

2

Motion Alert Mode

Alert CALL or SMS or NONE [Only in SMS Working mode]

5

3

Motion Threshold

Accelerometer threshold from 6 to 25

1

4

Contact Number

Contact number to be used for sending SMS or CALL

16

5

APN Name

Your network providers APN name

20

6

APN User Name

Your network providers APN user name if any

20

7

APN Password

Your network providers APN password if any

20

8

HTTP URL

URL of HTTP post request made in HTTP mode

150

9

HTTP Key

Any AUTH key of HTTP post request made in HTTP mode

100

A

Ping Interval

Location sending interval in seconds

4

B

MQTT Host

IP / Domain of MQTT broker in MQTT/TCP mode

30

C

MQTT Port

Port of MQTT broker accepting data in MQTT/TCP mode

10

D

MQTT Client ID

MQTT client ID of MQTT broker in MQTT/TCP mode

20

E

MQTT Topic

MQTT Topic of MQTT broker in MQTT/TCP mode

30

F

MQTT Protocol Name

Protocol name of MQTT broker in MQTT/TCP mode

10

G

MQTT LVL

LVL value of MQTT broker in MQTT/TCP mode

1

H

MQTT Flags

Flags used in MQTT packets in MQTT/TCP mode

1

I

MQTT Keep Alive

Keep alive interval for MQTT connection

4

J

MQTT User Name

MQTT authentication user name

30

K

MQTT Password

MQTT authentication password

35

Z

Return or Exit Bluetooth

Returns from the Bluetooth loop and restarts device

0

Writing new parameter values to the device :

When you want to update a parameters value, you need to write to the TX characteristic given above.

The format to write data is as follows,

InputData = '$VALETRON:' + InputIndex + '-' + $('#i'+InputID).val() + '#';

If you look at the above line, its a JavaScript line which forms the command to be sent to the device.

ex.,

if you want to update the Contact Number parameter to 1234567890, the command will become,

$VALETRON:4-1234567890#

Here the content between - (hyphen) and # (hash) characters which is 1234567890 will be written to the Contact Number parameter whose index is 4.

“$VALETRON:” is the header and the “#” is like the footer which help the device to parse the command easily.

Once you have formed this command, you have to send the command, in a certain byte format to the device, Look at this code JavaScript code below,

for(var i=0;i<InputData.length;i++)
{
    data1[0] = 0x01; // Packet Identifer - Parameter Ppdate Packet
    data1[1] = InputData.charCodeAt(i);
            
    ble.writeWithoutResponse(
        deviceId,
        bluefruit.serviceUUID,
        bluefruit.txCharacteristic,
        data1.buffer, success, failure
    );
}

Here we are sending 0x01 as the first byte and our command byte as the second byte. Here 0x01 is a packet identifier that indicates to the device that the byte that follows is a parameter update data.

ex.,

Our data will be sent to device like this,

0x01, $

0x01, V

0x01, A etc

Reading values from the device :

When you want to read anything from the device, you subscribe to the RX characteristic given above.

Whenever a data is available, the phone is notified by Bluetooth.

When you want to manually read the parameters, Everything explained above holds good and you just need to replace the first byte, which is the packet identifier with data1[0] = 0x02; to indicate that its a parameter read command in below code snippet.

for(var i=0;i<InputData.length;i++)
{
    data1[0] = 0x02; // Packet Identifer - Parameter Read Packet
    data1[1] = InputData.charCodeAt(i);
            
    ble.writeWithoutResponse(
        deviceId,
        bluefruit.serviceUUID,
        bluefruit.txCharacteristic,
        data1.buffer, success, failure
    );
}

Here we are sending 0x02 as the first byte and our command byte as the second byte. Here 0x02 is a packet identifier that indicates to the device that the byte that follows is a parameter read data.

ex.,

Our data will be sent to device like this,

0x02, $

0x02, V

0x02, A etc

For example,

You can read the contact number parameter with $VALETRON:4-000# command.

Last updated