# 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 :

<table data-header-hidden><thead><tr><th width="95"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><strong>Index</strong></td><td><strong>Command Name</strong></td><td><strong>Description</strong></td><td><strong>Size [Bytes]</strong></td></tr><tr><td>0</td><td>Band</td><td>Network band to be selected, Best to leave default</td><td>30</td></tr><tr><td>1</td><td>Working Mode</td><td>Devices location sending mode HTTP / TCP / SMS</td><td>5</td></tr><tr><td>2</td><td>Motion Alert Mode</td><td>Alert CALL or SMS or NONE [Only in SMS Working mode]</td><td>5</td></tr><tr><td>3</td><td>Motion Threshold</td><td>Accelerometer threshold from 6 to 25</td><td>1</td></tr><tr><td>4</td><td>Contact Number</td><td>Contact number to be used for sending SMS or CALL</td><td>16</td></tr><tr><td>5</td><td>APN Name</td><td>Your network providers APN name</td><td>20</td></tr><tr><td>6</td><td>APN User Name</td><td>Your network providers APN user name if any</td><td>20</td></tr><tr><td>7</td><td>APN Password</td><td>Your network providers APN password if any</td><td>20</td></tr><tr><td>8</td><td>HTTP URL</td><td>URL of HTTP post request made in HTTP mode</td><td>150</td></tr><tr><td>9</td><td>HTTP Key</td><td>Any AUTH key of HTTP post request made in HTTP mode</td><td>100</td></tr><tr><td>A</td><td>Ping Interval</td><td>Location sending interval in seconds</td><td>4</td></tr><tr><td>B</td><td>MQTT Host</td><td>IP / Domain of MQTT broker in MQTT/TCP mode</td><td>30</td></tr><tr><td>C</td><td>MQTT Port</td><td>Port of MQTT broker accepting data in MQTT/TCP mode</td><td>10</td></tr><tr><td>D</td><td>MQTT Client ID</td><td>MQTT client ID of MQTT broker in MQTT/TCP mode</td><td>20</td></tr><tr><td>E</td><td>MQTT Topic</td><td>MQTT Topic of MQTT broker in MQTT/TCP mode</td><td>30</td></tr><tr><td>F</td><td>MQTT Protocol Name</td><td>Protocol name of MQTT broker in MQTT/TCP mode</td><td>10</td></tr><tr><td>G</td><td>MQTT LVL</td><td>LVL value of MQTT broker in MQTT/TCP mode</td><td>1</td></tr><tr><td>H</td><td>MQTT Flags</td><td>Flags used in MQTT packets in MQTT/TCP mode</td><td>1</td></tr><tr><td>I</td><td>MQTT Keep Alive</td><td>Keep alive interval for MQTT connection</td><td>4</td></tr><tr><td>J</td><td>MQTT User Name</td><td>MQTT authentication user name</td><td>30</td></tr><tr><td>K</td><td>MQTT Password</td><td>MQTT authentication password</td><td>35</td></tr><tr><td>Z</td><td>Return or Exit Bluetooth</td><td>Returns from the Bluetooth loop and restarts device</td><td>0</td></tr></tbody></table>

### 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.valetron.com/wiki/products/valtrack-v4-vts-io-int-lte/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
