# Commanding Connectivity Modules

You can send commands to Connectivity Modules to perform certain actions. Some commands like Restart, Ping are valid across all Connectivity modules, and some commands are only applicable to certain Connectivity Modules and applications running on them.

You will always use `physical-devices` endpoint to send these instructions to Connectivity Modules so you need to retrieve corresponding `id_physical_device` using [Physical device endpoint](https://docs.bace-iot.com/navigating-data#navigating-physical-devices).&#x20;

### List of Standard commands

The following standard commands below works with corresponding Connectivity Modules regardless of the application it is running.

<table><thead><tr><th width="175">Endpoint Name</th><th>Description</th><th width="287">Modules</th></tr></thead><tbody><tr><td><code>ping</code></td><td>It will ping the Connectivity Module</td><td>GO/CORE/PLUS</td></tr><tr><td><code>restart</code></td><td>Restarts Connectivity Module</td><td>GO/CORE/PLUS</td></tr><tr><td><code>self-test</code></td><td>Provides a list of information about the module</td><td>GO/CORE/PLUS</td></tr><tr><td><code>request-measurement</code></td><td>Forces Module to request measurement from all assets connected to it</td><td>GO/CORE/PLUS</td></tr><tr><td><code>wifi</code></td><td>Scan, connect or disconnect from a WiFi Access point</td><td>PLUS/CORE</td></tr></tbody></table>

## Ping IoT connectivity module

<mark style="color:blue;">`GET`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/ping`

Pinging IoT connectivity module will tell if it is online or offline

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK Succesful Ping" %}

```json
{
    "status": 200,
    "payload": {
        "data": "pong",
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Unsuccesful ping (offline device)" %}

```javascript
{
    "name": "Not Found",
    "message": "The operation Ping failed because the requested device isn't online or does not support this operation.",
    "code": 0,
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Restart IoT connectivity module

<mark style="color:green;">`POST`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/restart`

Sends a command to restart IoT connectivity module

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK Successful Restart" %}

```json
{
    "status": 200,
    "payload": {
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Unsuccessful restart" %}

```json
{
    "name": "Not Found",
    "message": "The requested record with id 087dbbca-4efd-47df-949d-0cb8fcf61c5c could not be found or is inaccessible",
    "code": 0,
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Performs Self-test for IoT connectivity module

<mark style="color:blue;">`GET`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/status`

Sends a command to perform self-test for IoT connectivity module. Response could help support troubleshooting connectivity related problems.

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK Successful Selftest" %}

```json
{
    "status": 200,
    "payload": {
        "isGnssOk": true,
        "isModemConnected": true,
        "isInputVoltageOk": true,
        "inputVoltage": 11.671,
        "isAteccOk": false,
        "ModemInfo": "+CPSI: LTE CAT-M1,Online,204-08,0x7EF7,18189068,113,EUTRAN-BAND20,6400,3,3,-16,-98,-66,10\r\n",
        "WifiInfo": "1c3bf37aee5a,9,-44",
        "EthernetInfo": "NA",
        "SatsInView": 12,
        "SatsInUse": 8,
        "uptime": 12582,
        "minFreeHeap": 4065391,
        "freeHeap": 4088163,
        "internalFreeHeap": 60987,
        "minInternalFreeHeap": 50231,
        "externalFreeHeap": 4027563,
        "minExternalFreeHeap": 4015283,
        "nvsUsedEntries": 165,
        "nvsFreeEntries": 7899,
        "spiffsUsage": 502,
        "spiffsTotal": 11615276,
        "isSpiffsOk": true,
        "resetCause": "SW",
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Unsuccessful selftest" %}

```json
{
    "name": "Not Found",
    "message": "The operation SelfTest failed because the requested device isn't online or does not support this operation.",
    "code": 0,
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Request measurement from connected assets

<mark style="color:orange;">`PUT`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/request-measurement`

Instructs IoT connectivity module to request the latest measurements from all connected assets or sensors.

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK Successful" %}

```json
{
    "status": 200,
    "payload": {
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="404: Not Found Unsuccessful" %}

```json
{
    "name": "Not Found",
    "message": "The operation RequestMeasurement failed because the requested device isn't online or does not support this operation.",
    "code": 0,
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Scan nearby WiFi Access Points

<mark style="color:blue;">`GET`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/wifi`

WiFi endpoint is used for retrieving nearby WiFi Access points.

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": 200,
    "payload": {
        "wifiAccessPoints": [
            {
                "ssid": "",
                "macAddress": "223bf37aee5a",
                "signalStrength": -42,
                "channel": 9
            },
            {
                "ssid": "",
                "macAddress": "223bf37aed1c",
                "signalStrength": -68,
                "channel": 9
            },
            {
                "ssid": "billa TC",
                "macAddress": "f099bf06c428",
                "signalStrength": -72,
                "channel": 6
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "342cc45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo",
                "macAddress": "362c945a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Saskia vd Meijden-Bessems",
                "macAddress": "362cb45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "362cd45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d703d0",
                "signalStrength": -75,
                "channel": 6
            },
            {
                "ssid": "Mein7490",
                "macAddress": "1ced6fe4dc05",
                "signalStrength": -75,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "0aa030d703d3",
                "signalStrength": -76,
                "channel": 6
            },
            {
                "ssid": "",
                "macAddress": "8c8580792c71",
                "signalStrength": -77,
                "channel": 6
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1cfee7",
                "signalStrength": -79,
                "channel": 3
            },
            {
                "ssid": "Mein7490",
                "macAddress": "3810d5279801",
                "signalStrength": -81,
                "channel": 11
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1cfee7",
                "signalStrength": -82,
                "channel": 3
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1cfee7",
                "signalStrength": -83,
                "channel": 3
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d70420",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "0aa030d70423",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "Mein7490",
                "macAddress": "ccce1ef8e3ee",
                "signalStrength": -88,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1ca8c5",
                "signalStrength": -90,
                "channel": 3
            },
            {
                "ssid": "Yilanci",
                "macAddress": "98ded0a4674d",
                "signalStrength": -91,
                "channel": 11
            },
            {
                "ssid": "DIRECT-4E-HP ENVY 4520 series",
                "macAddress": "48ba4e13d54f",
                "signalStrength": -93,
                "channel": 6
            }
        ],
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="501: Not Implemented " %}

```javascript
{
    "status": 501,
    "payload": {
        "result": "failed",
        "cause": "Wifi disabled"
    }
}
```

{% endtab %}
{% endtabs %}

## Connect to a WiFi Access Point

<mark style="color:orange;">`PUT`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/wifi`

WiFi endpoint is used for connecting to nearby WiFi Access point.

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

#### Request Body

| Name                                   | Type   | Description      |
| -------------------------------------- | ------ | ---------------- |
| ssid<mark style="color:red;">\*</mark> | string | name of the ssid |
| password                               | string | test             |

{% tabs %}
{% tab title="200: OK Successful response returning SSIDs" %}

```json
{
    "status": 200,
    "payload": {
        "wifiAccessPoints": [
            {
                "ssid": "",
                "macAddress": "223bf37aee5a",
                "signalStrength": -42,
                "channel": 9
            },
            {
                "ssid": "",
                "macAddress": "223bf37aed1c",
                "signalStrength": -68,
                "channel": 9
            },
            {
                "ssid": "billa TC",
                "macAddress": "f099bf06c428",
                "signalStrength": -72,
                "channel": 6
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "342cc45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo",
                "macAddress": "362c945a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Saskia vd Meijden-Bessems",
                "macAddress": "362cb45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "362cd45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d703d0",
                "signalStrength": -75,
                "channel": 6
            },
            {
                "ssid": "Mein7490",
                "macAddress": "1ced6fe4dc05",
                "signalStrength": -75,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "0aa030d703d3",
                "signalStrength": -76,
                "channel": 6
            },
            {
                "ssid": "",
                "macAddress": "8c8580792c71",
                "signalStrength": -77,
                "channel": 6
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1cfee7",
                "signalStrength": -79,
                "channel": 3
            },
            {
                "ssid": "Mein7490",
                "macAddress": "3810d5279801",
                "signalStrength": -81,
                "channel": 11
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1cfee7",
                "signalStrength": -82,
                "channel": 3
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1cfee7",
                "signalStrength": -83,
                "channel": 3
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d70420",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "0aa030d70423",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "Mein7490",
                "macAddress": "ccce1ef8e3ee",
                "signalStrength": -88,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1ca8c5",
                "signalStrength": -90,
                "channel": 3
            },
            {
                "ssid": "Yilanci",
                "macAddress": "98ded0a4674d",
                "signalStrength": -91,
                "channel": 11
            },
            {
                "ssid": "DIRECT-4E-HP ENVY 4520 series",
                "macAddress": "48ba4e13d54f",
                "signalStrength": -93,
                "channel": 6
            }
        ],
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="501: Not Implemented Unsuccessful response from a WiFi disabled device" %}

```javascript
{
    "status": 501,
    "payload": {
        "result": "failed",
        "cause": "Wifi disabled"
    }
}
```

{% endtab %}
{% endtabs %}

## Disconnects from the current WiFi Access Point

<mark style="color:red;">`DELETE`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/{id}/wifi`

Delete method will disconnect gateway from the WiFi Access point

#### Path Parameters

| Name                                 | Type   | Description                    |
| ------------------------------------ | ------ | ------------------------------ |
| id<mark style="color:red;">\*</mark> | string | Gateway's id\_physical\_device |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": 200,
    "payload": {
        "wifiAccessPoints": [
            {
                "ssid": "",
                "macAddress": "223bf37aee5a",
                "signalStrength": -42,
                "channel": 9
            },
            {
                "ssid": "",
                "macAddress": "223bf37aed1c",
                "signalStrength": -68,
                "channel": 9
            },
            {
                "ssid": "billa TC",
                "macAddress": "f099bf06c428",
                "signalStrength": -72,
                "channel": 6
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "342cc45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo",
                "macAddress": "362c945a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Saskia vd Meijden-Bessems",
                "macAddress": "362cb45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "362cd45a3d22",
                "signalStrength": -75,
                "channel": 1
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d703d0",
                "signalStrength": -75,
                "channel": 6
            },
            {
                "ssid": "Mein7490",
                "macAddress": "1ced6fe4dc05",
                "signalStrength": -75,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "0aa030d703d3",
                "signalStrength": -76,
                "channel": 6
            },
            {
                "ssid": "",
                "macAddress": "8c8580792c71",
                "signalStrength": -77,
                "channel": 6
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1cfee7",
                "signalStrength": -79,
                "channel": 3
            },
            {
                "ssid": "Mein7490",
                "macAddress": "3810d5279801",
                "signalStrength": -81,
                "channel": 11
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1cfee7",
                "signalStrength": -82,
                "channel": 3
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1cfee7",
                "signalStrength": -83,
                "channel": 3
            },
            {
                "ssid": "Ziggo9025459",
                "macAddress": "0aa030d70420",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "",
                "macAddress": "0aa030d70423",
                "signalStrength": -88,
                "channel": 1
            },
            {
                "ssid": "Mein7490",
                "macAddress": "ccce1ef8e3ee",
                "signalStrength": -88,
                "channel": 11
            },
            {
                "ssid": "",
                "macAddress": "9cc9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI",
                "macAddress": "a2c9eb1ca8c5",
                "signalStrength": -89,
                "channel": 3
            },
            {
                "ssid": "FBI-Guest",
                "macAddress": "a6c9eb1ca8c5",
                "signalStrength": -90,
                "channel": 3
            },
            {
                "ssid": "Yilanci",
                "macAddress": "98ded0a4674d",
                "signalStrength": -91,
                "channel": 11
            },
            {
                "ssid": "DIRECT-4E-HP ENVY 4520 series",
                "macAddress": "48ba4e13d54f",
                "signalStrength": -93,
                "channel": 6
            }
        ],
        "result": "success"
    }
}
```

{% endtab %}

{% tab title="501: Not Implemented " %}

```javascript
{
    "status": 501,
    "payload": {
        "result": "failed",
        "cause": "Wifi disabled"
    }
}
```

{% endtab %}
{% endtabs %}

### List of Application Specific Commands

For some projects, a project specific application is developed to control connected assets in a certain way. Some examples of these types of Application Specific Commands are:

* Instructing Connectivity Module to run a measurement routine, do some math calculations and control relays connected to it.
* Send counter reset command to a flow meter connected to Connectivity module via RS232.

## Reset main counter

<mark style="color:orange;">`PUT`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/:id/reset-main-counter`

Command used to restart flow meter main counter

{% tabs %}
{% tab title="200: OK Successful request" %}

```javascript
{
    "status": "200",
}
```

{% endtab %}

{% tab title="400: Bad Request Unsuccessful request" %}

```javascript
{
    "name": "Bad Request",
    "message": "This device is offline or does not support this method.",
    "code": 0,
    "status": 400,
    "type": "yii\\web\\BadRequestHttpException"
}
```

{% endtab %}
{% endtabs %}

## Reset daily counter

<mark style="color:orange;">`PUT`</mark> `https://dashboard.bace-iot.com/api/v2/physical-device/:id/reset-daily-counter`

Command used to restart flow meter daily counter

{% tabs %}
{% tab title="200: OK Successful request" %}

```javascript
{
    "status": "200",
}
```

{% endtab %}

{% tab title="400: Bad Request Unsuccessful request" %}

```javascript
{
    "name": "Bad Request",
    "message": "This device is offline or does not support this method.",
    "code": 0,
    "status": 400,
    "type": "yii\\web\\BadRequestHttpException"
}
```

{% endtab %}
{% endtabs %}


---

# 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.bace-iot.com/api/commanding-connectivity-modules.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.
