-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Jon Hall edited this page May 22, 2018
·
11 revisions
By default, Swill SDK assumes your CraftBeerPi3 HTTP and websocket servers are both located at http://localhost:5000. This is normally fine if you haven't configured custom ports and routing for your CBPi instance.
If you are running the your code on another machine, host or port entirely, you will need to tell the SDK where to look for CraftBeerPi. Those overrides are provided in the form of a configuration object you pass to Swill SDK with the following properties:
| Property | Default Value | Description |
|---|---|---|
server |
http://localhost |
The address of CBPi server to communicate with. |
port |
5000 |
The port of the CBPi server. |
cacheInterval |
5000 |
The interval with which to retrieve new data from the CBPi server, in milliseconds. |
Sample code:
const sdk = SwillSDK({
server: 'http://192.168.1.123',
port: 5000,
cacheInterval: 10000
});The initialization function will return a SDK object with the following exports:
| Property | Wiki | Description |
|---|---|---|
resources |
Resources | A resources object, containing all of the base-level resources that CraftBeerPi operates with (kettles, actors, etc.) |
httpClient |
HTTP Client | The HTTP client that the SDK uses to communicate with CraftBeerPi. |
socketClient |
Socket Client | A websocket client, wrapping the CraftBeerPi events interface. |
config |
Config | CraftBeerPi system configuration (temperature unit, brewery name, port, etc.). |