Module Integration Guides
Building a custom client

Connecting to Bytebeam cloud

5min

Download the device auth json file

We use TLS Mutual authentication to connect a device to the cloud. Mutual authentication means that both the server and the client authenticate each other before the connection is setup. Three files are required for this authentication to happen correctly

  1. CA Certificate: This file is used by the device to authenticate the server certificate and hence the server
  2. Client Certificate: This file is used by the device to authenticate itself to the server
  3. Client Private Key: This file is also used by the device to authenticate itself to the server.

Bytebeam provides a single json file that contains the contents of these three files. You can download the json file by Provisioning a Device. This should give you a file like the below:

JSON


Note: The certificates and keys in the above file and rest of this guide are fake and won't actually work. You have to use the json file downloaded from the provisioning guide above.

Let us extract the ca_certificate, device_certificate and device_private_key into three files. We will connect to Bytebeam cloud using these files and MQTTX. Note the "\n" characters in the strings. When extracting these into individual files we need to replace them with newlines. Here is how the three files would look like

ca_certificate.pem
device_certificate.pem
device_private_key.pem


Connect using MQTTX

Now open MQTTX and click on + New Connection to create a new connection:

Document image


Fill in the Name, Client ID, Host, Port as shown below. For the certificate field select "CA or self signed certificates" and upload the files we have extracted above.

Document image


Select MQTT 3.1.1 as the protocol version in the advanced settings:

Document image


Click on the Connect button on the top right and you should see a successful connection.

Document image


Any errors need to be fixed before proceeding further with the guide.

Building this into your SDK

Now that we have understood how to connect to bytebeam you can implement this programatically in your client. You can follow the below steps:

  1. The first step towards building a client is figuring out how to implement MQTT. mqtt.org has a list of client libraries for various operating systems and langauges. If you are using a GSM modem in AT command mode it is possible that your modem comes built in with MQTT commands as well.
  2. Once you have figured out an MQTT implementation, you can write code to connect using the certificates and private key downloaded from cloud. Note that we support only TLS 1.2 and above. Most modern systems support this version. Also note that bytebeam expects each device to present a unique MQTT client id. You can do this by constructing the client id as "client-<tenant-id>-<device-id>".
  3. Make sure to handle disconnections and reconnect as required.