exparticle v0.0.5 ExParticle

Provides access to the Particle Cloud API.

Summary

Functions

Call a function exposed by the device, with arguments passed in the request body

Claim a new or unclaimed device to your account

Generate a device claim code that allows the device to be successfully claimed to a user’s account during the SoftAP setup process

Get basic information about the given device, including the custom variables and functions it has exposed

Request the current value of a variable exposed by the device

List devices the currently authenticated user has access to

Events will start listening on all the events generated by the device

Request device transfer from another user

Functions

call_function(device_id, function, args)

Call a function exposed by the device, with arguments passed in the request body.

Params:

  • device_id
  • function_name
  • args
  • format

Example:

iex> ExParticle.call_function(“device_id”, “function_name”, “args”) %{connected: true, id: “device_id”, last_app: “”, return_value: 1}

claim_device(device_id)

Claim a new or unclaimed device to your account.

Params:

  • device_id

Example: iex(1)> ExParticle.claim_device(“423o54o56664356243455t6”) %{connected: true, id: “423o54o56664356243455t6”, ok: true,

user_id: "56630100e5a6cbe63b0000c6"}
create_claims()

Generate a device claim code that allows the device to be successfully claimed to a user’s account during the SoftAP setup process.

Example

iex> ExParticle.create_claims %{claim_code: “i31YZ5bRq9Z9xxX+YgGO6rY+DDJn6CzFpNA02wiBF9SvIgYbW3QtIhgnYVAt0Ow”,

device_ids: ["device_id"]}
device_info(device_id)

Get basic information about the given device, including the custom variables and functions it has exposed.

Params:

  • device_id

Example

iex> ExParticle.device_info(“decice_id”) %ExParticle.Model.DeviceInfo{ cc3000_patch_version: “wl0: Nov 7 2014 16:03:45 version 5.90.230.12 FWID 01-212234f8”, connected: false, functions: nil, id: “decice_id”, last_heard: nil, name: “my_iot”, product_id: 6, status: “normal”, variables: nil}

device_vars(device_id, var_name)

Request the current value of a variable exposed by the device.

Params:

  • device_id
  • var_name

Example:

iex> ExParticle.device_vars(“device_id”, “analogvalue”) %{cmd: “VarReturn”,

coreInfo: %{connected: true, deviceID: "device_id",
  last_app: "", last_handshake_at: "2015-12-29T20:16:03.762Z",
  last_heard: "2015-12-29T20:16:33.010Z", product_id: 6}, name: "analogvalue",
result: 0}
devices()

List devices the currently authenticated user has access to.

Example

iex> ExParticle.devices [%ExParticle.Model.Device{connected: true, id: “device_id”,

last_app: nil, last_heard: "2015-12-28T22:58:35.066Z",
last_ip_address: "192.168.11.10", name: "my_iot", product_id: 6,
status: "normal"}]
events(function)

Events will start listening on all the events generated by the device

Params

  • function

Example

iex> ExParticle.events( fn(event) -> IO.inspect(event) end ) :ok %ExParticle.Model.SseEvent{coreid: “423o54o56664356243455t6”, data: “19.600000”, name: “temperature”, published_at: “2016-03-14T10:40:38.065Z”, ttl: “60”} %ExParticle.Model.SseEvent{coreid: “423o54o56664356243455t6”, data: “48.900000”, name: “humidity”, published_at: “2016-03-14T10:40:40.065Z”, ttl: “60”}

request_transfer(device_id)

Request device transfer from another user.

Params:

  • device_id

Example:

iex(1)> ExParticle.request_transfer(“device_id”) %{connected: true, id: “device_id”, ok: true,

user_id: "56630100e5a6cbe63b0000c6"}
start()