# Devices

Manage devices in your account using this endpoint.

# List devices

Lists all devices for a particular account.

GET  /devices/?page={page}&search={search}&sortOrder={asc|desc}&itemsPerPage=10 

Example request

$ curl https://console.radiobridge.com/api/visualization/v1/devices/?page={page}&search={search}&sortOrder={asc|desc}&itemsPerPage=10

Example response

{
  "data": [
    {
      "id": 29,
      "device_id": "8C45000000D65A1A",
      "device_type_id": 40,
      "device_type_name": "RBS301-TILT - LoRa Tilt Sensor",
      "device_name": "Office 1 Tilt Sensor",
      "network_name": "Multitech - Radio Bridge account",
      "last_seen": "2021-09-03 04:49:07",
      "region": "US915",
      "join_eui": "0101010101010101",
      "is_active": "Active",
      "subscription": null,
      "gateway": null,
      "extra_notes": null,
      "created_at": "2018-04-11T22:18:28.000000Z",
      "commissioned_at": "2019-05-30T14:19:23.000000Z",
      "user": "User {Object}"
    }
  ],
  "payload": {
    "page": "1",
    "search": "",
    "sortOrder": "asc",
    "itemsPerPage": "1",
    "scope": "user"
  },
  "links": {
    "first": "https://console.radiobridge.com/api/visualization/v1/devices?page=1",
    "last": "https://console.radiobridge.com/api/visualization/v1/devices?page=10",
    "prev": null,
    "next": "https://console.radiobridge.com/api/visualization/v1/devices?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 10,
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "active": false
      },
      {
        "url": "https://console.radiobridge.com/api/visualization/v1/devices?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": "http://radiobridge.test/api/visualization/v1/devices?page=2",
        "label": "Next »",
        "active": false
      }
    ],
    "path": "http://radiobridge.test/api/visualization/v1/devices",
    "per_page": "1",
    "to": 1,
    "total": 10
  }
}

# List Device Types

List all device types supported by Console.

GET  /get-device-types?itemsPerPage=1000&network=3&sortBy=type_name&sortOrder=desc

Example response

{
  "data": [
    {
      "id": 60,
      "type_name": "WXT530 Weather Station",
      "part_number": "RBS306-VWS",
      "full_name": "RBS306-VWS - WXT530 Weather Station"
    },
    {
      "id": 62,
      "type_name": "Wireless Compass Sensor",
      "part_number": "RBS306-CMPS",
      "full_name": "RBS306-CMPS - Wireless Compass Sensor"
    }
  ],
  "payload": {
    "itemsPerPage": "1000",
    "network": "3",
    "sortBy": "type_name",
    "sortOrder": "desc"
  },
  "links": {
    "first": "http:\/\/radiobridge.test\/api\/visualization\/v1\/get-device-types?page=1",
    "last": "http:\/\/radiobridge.test\/api\/visualization\/v1\/get-device-types?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "links": [
      {
        "url": null,
        "label": "« Previous",
        "active": false
      },
      {
        "url": "http:\/\/radiobridge.test\/api\/visualization\/v1\/get-device-types?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ],
    "path": "http:\/\/radiobridge.test\/api\/visualization\/v1\/get-device-types",
    "per_page": "1000",
    "to": 39,
    "total": 39
  }
}

# Network Data

When user selects a network to create a device then form requires some additional fields based on selected network. This endpoint returns the field configuration data to show on the form.

GET  /network-data?gateway=multitech
Property Description
gateway (required) allowed options: machineq,senet,thethingsnetwork,loriot,multitech,chirpstack,kerlink,helium, aws_iot_core

Example response

{
    "regions": [],
    "gateways": [
        {
            "id": 196,
            "name": "Deepak Multitech Gateway",
            "gateway_bridge": "lora_multitech",
            "gateway_ip": null,
            "gateway_eui": null,
            "bridge": "Multitech (For lora devices)",
            "uuid": "9e7c190f-84cf-11eb-9dfd-0acf3b849a0a",
            "created_at": "Nov 11, 2019 07:18 PM",
            "user": {
              "id": 1,
              "timezone_format": "Asia/Calcutta",
              "console_only": false,
              "timezone_id": 96,
              "identity": {
                "id": 1,
                "first_name": "Deepak",
                "last_name": "Maurya",
                "email": "example@radiobridge.com",
                "last_login": "2022-10-09 15:56:53",
                "joined_on": "2018-04-11T22:17:07.000000Z",
                "activated": 1
              }
            }
        }
    ],
    "frequencyPlans": []
}

# Create Device

Creates a new device. This requires 2 Steps.

  • Pre-confirmation step to validate the form and check if the device registration requires any billing

  • If it requires any billing then call the billing endpoint to setup user billing account.

  • Otherwise in next call pass the action parameter with confirm value to create the device. (This step will again validate if the user account is valid and active billing (only if required to add the device) is setup to add the device.)

GET  /devices

Example request - Pre Registration

curl --location --request POST 'https://console.radiobridge.com/api/visualization/v1/devices' \
--header 'Organization: 1' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "network": 3,
    "gatewayName": "multitech",
    "gatewayId": 196,
    "deviceName": "Test Device",
    "deviceId": "ABCDE12345678901",
    "deviceKey": "ABCDE12345678901",
    "deviceType": 16,
    "deviceGateway": null,
    "mfatoken": null,
    "appRegion": null,
    "frequencyPlan": null,
    "registerMethod": "radiobridge",
    "consoleOnly": false,
    "action": "validate"
}'

Example request body - Pre Registration

{
  "network": 3,
  "gatewayName": "multitech",
  "gatewayId": 196,
  "deviceName": "Test Device",
  "deviceId": "ABCDE12345678901",
  "deviceKey": "ABCDE12345678901",
  "deviceType": 16,
  "deviceGateway": null,
  "mfatoken": null,
  "appRegion": null,
  "frequencyPlan": null,
  "registerMethod": "radiobridge",
  "consoleOnly": false,
  "action": "validate"
}

Example response - Pre Registration

{
  "status": true,
  "payment": {
    "demoDevice": false,
    "isDemoAccount": 0,
    "plan": false,
    "subscribed": false,
    "isOnTrial": "Feb 28, 2022 00:00:00 (UTC)"
  }
}

Example Error

{
    "message": "The given data was invalid.",
    "errors": {
        "deviceKey": [
            "App key should be 32 characters"
        ]
    }
}

If the device requires a payment then plan field will contain details of the payment, otherwise proceed with device registration.

Example request - Final Registration

curl --location --request POST 'https://console.radiobridge.com/api/visualization/v1/devices' \
--header 'Organization: 1' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "network": 3,
    "gatewayName": "multitech",
    "gatewayId": 196,
    "deviceName": "Test Device",
    "deviceId": "ABCDE12345678901",
    "deviceKey": "ABCDE12345678901ABCDE12345678901",
    "deviceType": 16,
    "deviceGateway": null,
    "mfatoken": null,
    "appRegion": null,
    "frequencyPlan": null,
    "registerMethod": "radiobridge",
    "consoleOnly": false,
    "action": "confirm"
}'

Example response - Final Registration

{
    "status": true,
    "device": {
        "id": 4330,
        "device_id": "ABCDE12345678901",
        "deviceTypeId": "16",
        "device_name": "Test Device",
        "device_type_name": "RBS301-DWS - LoRa Door\/Window",
        "is_active": "active",
        "subscription": null,
        "gateway": null,
        "extra_notes": null,
        "network_name": "Multitech - Radio Bridge account",
        "created_at": "2021-12-24T17:17:15.000000Z",
        "commissioned_at": "2021-12-24T17:17:15.000000Z",
        "user": "User {Object}",
        "last_seen": "--",
        "device_status": {
            "lastmsg_time": "Dec 24, 2021 17:17:15 (UTC)",
            "battery": "--",
            "tamper": "--",
            "tamper_detect_since_reset": "--",
            "config_error": "--",
            "rate_limit_status": "No",
            "current_sensor_state": "--",
            "hardware_version": "--",
            "firmware_version": "--",
            "low_battery": "--"
        }
    }
}

# Retrieve a Device

Returns a single Device.

GET  devices/{device_id}

Example request

curl https://console.radiobridge.com/api/visualization/v1/devices/{device_id}

Example response

{
  "data": {
    "id": 4318,
    "device_id": "{device_id}",
    "deviceTypeId": 25,
    "device_name": "TEMP/HUMID Sensor 3 --(Server Room Under Floor Panel)",
    "device_type_name": "RBS305-ATH - LoRa Air Temperature and Humidity Sensor",
    "is_active": "Active",
    "subscription": null,
    "gateway": null,
    "extra_notes": "",
    "network_name": "Chirpstack - Radio Bridge account",
    "created_at": "2021-11-09T21:01:43.000000Z",
    "commissioned_at": "2021-11-09T21:01:43.000000Z",
    "user": "User {Object}",
    "last_seen": "2021-11-18 13:50:30",
    "device_status": {
      "lastmsg_time": "Nov 18, 2021 13:50:30 (UTC)",
      "battery": "3.0V",
      "tamper": "Yes",
      "tamper_detect_since_reset": "Yes",
      "config_error": "No",
      "rate_limit_status": "No",
      "current_sensor_state": "19.6C",
      "hardware_version": "2.0",
      "firmware_version": "2.0.1",
      "low_battery": "No"
    }
  }
}

# Update a device

Updates the properties of a particular device.

Property Description
device_name (required) the name of the device
PATCH  /devices/{device_id}

Example request

curl --location --request PATCH 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "device_name": "Test Device"
}'

Example request body

{
  "device_name": "Test Device"
}

Example response

{
  "data": {
    "id": 4318,
    "device_id": "{device_id}",
    "deviceTypeId": 25,
    "device_name": "Test Device",
    "device_type_name": "RBS305-ATH - LoRa Air Temperature and Humidity Sensor",
    "is_active": "Active",
    "subscription": null,
    "gateway": null,
    "extra_notes": "",
    "network_name": "Chirpstack - Radio Bridge account",
    "created_at": "2021-11-09T21:01:43.000000Z",
    "commissioned_at": "2021-11-09T21:01:43.000000Z",
    "user": "User {Object}",
    "last_seen": "2021-11-18 13:50:30",
    "device_status": {
      "lastmsg_time": "Nov 18, 2021 13:50:30 (UTC)",
      "battery": "3.0V",
      "tamper": "Yes",
      "tamper_detect_since_reset": "Yes",
      "config_error": "No",
      "rate_limit_status": "No",
      "current_sensor_state": "19.6C",
      "hardware_version": "2.0",
      "firmware_version": "2.0.1",
      "low_battery": "No"
    }
  }
}

# Delete a device

Delete a device from the account, This action will adjust billing as per the account plan.

DELETE /devices/{device_id}

Example request

curl --location --request DELETE 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>'

Example response

HTTP 204

List all the uplinks for a device. The response body will be a UplinkCollection.

DELETE /devices/{device_id}/uplink?page=1

Example request

curl --location --request GET 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=1' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>'

Example response

{
  "data": [
    {
      "id": 20276873,
      "did": 4318,
      "device_id": "{device_id}",
      "device_type_id": 25,
      "device_name": "Test Device",
      "event_type": "AIR_TEMP_HUMIDITY_SENSOR",
      "sensor_sequence": [
        8
      ],
      "decoded_object": {
        "eventDescription": "Periodic Report",
        "measurement": "19.6C",
        "humidity": "27.3%"
      },
      "decoded_message": "Temperature/Humidity Event: Periodic Report<br />\nTemperature in degrees Celsius: 19.6C, 27.3 %",
      "event_time": "2021-11-19T06:29:38.000000Z",
      "data": "180d0013601b30",
      "lat": 0,
      "lng": 0,
      "signal_bars": "good five-bars",
      "snr": 10.199999999999999289457264239899814128875732421875,
      "rssi": -84,
      "client_api_log": [],
      "additional_data": null
    }
  ],
  "payload": {
    "page": "1",
    "itemsPerPage": "1"
  },
  "links": {
    "first": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=1",
    "last": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=32",
    "prev": null,
    "next": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 32,
    "links": [
      {
        "url": null,
        "label": "&laquo; Previous",
        "active": false
      },
      {
        "url": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink?page=2",
        "label": "Next &raquo;",
        "active": false
      }
    ],
    "path": "https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/uplink",
    "per_page": 10,
    "to": 10,
    "total": 313
  }
}

Get the HTML form to configure a device, This returns a dynamic HTML for based on the device type.

HTML form uses bootstrap css class and contains 3 different section to configure 3 different type of downlinks.

Sensor Configuration Form General Configuration Form Advanced Configuration Form

GET /devices/{device_id}/configure/create

Example request

curl --location --request GET 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}/configure/create' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>'

Example response

<form method="post" class="submit_ajax_sendevent" action="https://console.radiobridge.com/send_event">
    <input type="hidden" name="deviceId" value="322">
            <input type="hidden" name="config_field[islorawan]" value="1">
        <input type="hidden" name="_token" value="w8ZNODSwXZ0VEWQUXOpjV2y9RZuOFDuXcN0QoPd5">

    <div class="toggle_config_sections">
        <div class="field_options toggle_field_full sensorconfig_method_toggle">
            <div class="toggle_disabled d-none"></div>
            <div class="btn-group" id="status" data-toggle="buttons">
                <label class="btn btn-default btn-on-2 btn-sm active"><input class="sensor_config_type" type="radio" value="sensor" name="config_field[config_type]" checked="checked">Sensor Config</label>
                <label class="btn btn-default btn-on-2 btn-sm "><input class="sensor_config_type" type="radio" value="general" name="config_field[config_type]" >General</label>
                <label class="btn btn-default btn-on-2 btn-sm "><input class="advanced_config_type" type="radio" value="advanced" name="config_field[config_type]" >Advanced</label>
            </div>
        </div>
    </div>
    <div class="eventconfigs" style="margin-top: 15px;">
        <div class="sensor_config_fields ">
        </div>
        <div class="general_config_fields d-none">
        </div>
        <div class="advanced_config_fields d-none">
        </div>
    </div>
</form>

Send a configuration change to the Device.

POST /devices/{device_id}/configure

Example request

curl --location --request POST 'https://console.radiobridge.com/api/visualization/v1/devices/{device_id}/configure' \
--header 'Organization: 1' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "config_field": {
        "islorawan": 1,
        "config_type": "sensor",
        "18": {
            "group": 19
        },
        "22": {
            "main": 1
        },
        "23": {
            "main": -10
        },
        "24": {
            "main": 20
        },
        "21": {
            "main": 151
        },
        "27": {
            "main": ""
        },
        "28": {
            "main": ""
        },
        "25": {
            "main": ""
        },
        "supervisory_period": "",
        "sampling_rate": "",
        "sampling_rate_ms": "",
        "sampling_period": "",
        "uplink_retries": "",
        "port_number": "",
        "rejoin_period": ""
    }
}'

Example request body

{
  "config_field": {
    "islorawan": 1,
    "config_type": "sensor",
    "18": {
      "group": 19
    },
    "22": {
      "main": 1
    },
    "23": {
      "main": -10
    },
    "24": {
      "main": 20
    },
    "21": {
      "main": 151
    },
    "27": {
      "main": ""
    },
    "28": {
      "main": ""
    },
    "25": {
      "main": ""
    },
    "supervisory_period": "",
    "sampling_rate": "",
    "sampling_rate_ms": "",
    "sampling_period": "",
    "uplink_retries": "",
    "port_number": "",
    "rejoin_period": ""
  }
}

Successful Example response

{
  "status":true,
  "message":"Downlink queued successfully."
}

Failed Example response

{
  "status": false,
  "message":"An error occurred, please check config history to view the log."
}

Retrieves downlinks history for a device.

GET /devices/{device_id}/configure

Example request

curl --location --request GET 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}/configure' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>'

Example response

[
  {
    "id": 2,
    "eventData": "",
    "configStatus": "Config Sent",
    "event_name": "event_sent",
    "publishedAt": "2021-12-24T14:40:07.000000Z"
  },
  {
    "id": 2,
    "eventData": "Config Type : Threshold<br />\nRestoral margin: <b>1</b><br />\nLower temperature threshold: <b>-10°C</b><br />\nUpper temperature threshold.: <b>20°C</b><br />\nPeriodic  Reporting: <b>24 Hours</b><br />\n<br />\n<br />\n<b>HEX:</b> 09001801f6140000",
    "configStatus": "New Config Created",
    "event_name": "event_created",
    "publishedAt": "2021-12-24T14:40:07.000000Z"
  }
]

Cancel last scheduled downlink, if all downlink are already sent to device then nothing will be cancelled.

DELETE /devices/{device_id}/configure/cancel

Example request

curl --location --request DELETE 'http://console.radiobridge.com/api/visualization/v1/devices/{device_id}/configure/cancel' \
--header 'Organization: <organization id>' \
--header 'Authorization: Bearer <token>'

Example response

{
  "status":true,
  "message":"Config message cancelled successfully."
}