The cb Command

Overview

If you have read through any of the tutorials, you will have seen that many things to do with bridges, bridge-apps and adaptors are modified using the cb command on your Raspberry Pi. This section contains a complete list of all the cb command options, together with some examples.

cb commands are used to create, modify and delete bridges, bridge-apps and devices (which actually contain information about a device and its adaptor). All commands require a user name and password, which can be provided using the --user and --password options. If you leave out one or both of these, you will be prompted for them and when you are asked for your password it will not be visible on the screen.

All cb commands have the options --post, --patch and --get. Those associated with apps and devices also have --delete. Bridges cannot be deleted. You can only access things that you own, which basically means bridges, apps and devices that you have created in the first place.

In the following sections, we will leave off the --user and --password options, but they are available with all commands. For example, you can type:

cb --bridge --post --user [email protected] --password mypassword

Bridge commands

All these commands must be typed on the bridge itself, ie on the Raspberry Pi that you have installed cbridge on.

# To create a bridge. This makes the Raspberry Pi on which the command is typed into a bridge
cb --bridge post

# To create a bridge and give it the name "mybridge"
cb --bridge post --name mybridge

# To get details of a bridge:
cb --bridge get

# To change the name of a bridge that you have already created
cb --bridge patch --name mybridge

🚧

thisbridge.sh

Creating a bridge, using the post option, adds some information into /opt/cbridge/thisbridge/thisbridge.sh. This includes the key that the bridge uses to access the bridge controller, and hence the rest of the Internet. It is therefore important that you don't delete or modify these liines.

App and device commands

These need to be typed on the Raspberry Pi on which you have developed the code for the associated app or adaptor, or, in fact, any Linux machine with cbridge installed on which you have cloned the GitHub repository for the app or adaptor. Each command needs the config.json filename associated with the app or adaptor.

📘

What's a config.json file?

See details in the sections on deploying apps and adaptors.

The examples below are for an app, but the same commands apply to a device and its adaptor; just replace --app with --device.

# To create an app
cb --app post config.json

# To modify an app (after changing config.json)
cb --app patch config.json

# To get details of the app
cb --app get config.json

# To delete the app
cb --app delete config.json

🚧

Information in config.json

When you create an app or device, some extra information is added to the config.json file. This is how cb knows how to access your app, so don't delete or alter it! The information is removed when you delete the app or device.

Next ...