Get device config.json configuration.
The intention of this module is to provide low level access to how a Resin.io device config.json
file is generated.
THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.
Install resin-device-config
by running:
$ npm install --save resin-device-config
- deviceConfig
- .generate(options, params) ⇒
Object
- .validate(config)
- .getByApplication(application, [options]) ⇒
Promise.<Object>
- .getByDevice(uuid, [options]) ⇒
Promise.<Object>
- .generate(options, params) ⇒
Kind: static method of deviceConfig
Summary: Generate a basic config.json object
Returns: Object
- config.json
Access: public
Param | Type | Description |
---|---|---|
options | Object |
options |
params | Object |
user params |
Example
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
id: 7
username: 'johndoe'
pubnub:
subscribe_key: 'demo'
publish_key: 'demo'
mixpanel:
token: 'e3bc4100330c35722740fb8c6f5abddc'
apiKey: 'asdf'
vpnPort: 1723
endpoints:
api: 'https://api.resin.io'
vpn: 'vpn.resin.io'
registry: 'registry.resin.io'
,
network: 'ethernet'
appUpdatePollInterval: 50000
console.log(config)
Kind: static method of deviceConfig
Summary: Validate a generated config.json object
Throws:
- Will throw if there is a validation error
Access: public
Param | Type | Description |
---|---|---|
config | Object |
generated config object |
Example
config = deviceConfig.generate
application:
app_name: 'HelloWorldApp'
id: 18
device_type: 'raspberry-pi'
user:
id: 7
username: 'johndoe'
pubnub:
subscribe_key: 'demo'
publish_key: 'demo'
mixpanel:
token: 'e3bc4100330c35722740fb8c6f5abddc'
apiKey: 'asdf'
vpnPort: 1723
endpoints:
api: 'https://api.resin.io'
vpn: 'vpn.resin.io'
registry: 'registry.resin.io'
,
network: 'ethernet'
appUpdatePollInterval: 50000
deviceConfig.validate(config)
Kind: static method of deviceConfig
Summary: Get a device configuration object from an application
Returns: Promise.<Object>
- device configuration
Access: public
Todo
- Move this to the SDK
Param | Type | Default | Description |
---|---|---|---|
application | String |
application name | |
[options] | Object |
{} |
options |
[options.wifiSsid] | String |
wifi ssid | |
[options.wifiKey] | String |
wifi key |
Example
deviceConfig.getByApplication 'App1',
network: 'wifi'
wifiSsid: 'foobar'
wifiKey: 'hello'
.then (configuration) ->
console.log(configuration)
Kind: static method of deviceConfig
Summary: Get a device configuration object from a device
Returns: Promise.<Object>
- device configuration
Access: public
Todo
- Move this to the SDK
Param | Type | Default | Description |
---|---|---|---|
uuid | String |
device uuid | |
[options] | Object |
{} |
options |
[options.wifiSsid] | String |
wifi ssid | |
[options.wifiKey] | String |
wifi key |
Example
deviceConfig.getByDevice '7cf02a6',
network: 'wifi'
wifiSsid: 'foobar'
wifiKey: 'hello'
.then (configuration) ->
console.log(configuration)
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Run the test suite by doing:
$ gulp test
- Issue Tracker: github.com/resin-io-modules/resin-device-config/issues
- Source Code: github.com/resin-io-modules/resin-device-config
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
The project is licensed under the Apache 2.0 license.