Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Particle Integrations [THAT Conference 2019]

Particle Integrations [THAT Conference 2019]

Brandon Satrom

August 05, 2019
Tweet

More Decks by Brandon Satrom

Other Decks in Technology

Transcript

  1. BUILDING WEB AND MOBILE APPS USING WEBHOOKS AND INTEGRATIONS PIPING

    DATA TO COMPUTE CLOUDS GETTING STARTED WITH THE CLI
  2. PARTICLE COMMAND-LINE INTERFACE (CLI) ✴ List all your devices ✴

    Setup a new device ✴ Call functions and get variables ✴ Publish and subscribe to events ✴ Create new projects ✴ Compile firmware and flash devices ✴ Search for and install libraries ✴ Setup webhooks
  3. PARTICLE COMMAND-LINE INTERFACE (CLI) ✴ List all your devices ✴

    Setup a new device ✴ Call functions and get variables ✴ Publish and subscribe to events ✴ Create new projects ✴ Compile firmware and flash devices ✴ Search for and install libraries ✴ Setup webhooks
  4. PARTICLE DOCTOR FOR DEVICE RECOVERY ✴ Update Device OS ✴

    Reset device antenna ✴ Reset IP configuration ✴ Reset SoftAP hotspot ✴ Clear EEPROM ✴ Clear Wi-Fi credentials ✴ Reset server and device key ✴ Flash the default Tinker app
  5. PARTICLE DOCTOR FOR DEVICE RECOVERY ✴ Update Device OS ✴

    Reset device antenna ✴ Reset IP configuration ✴ Reset SoftAP hotspot ✴ Clear EEPROM ✴ Clear Wi-Fi credentials ✴ Reset server and device key ✴ Flash the default Tinker app
  6. BUILDING WEB AND MOBILE APPS USING WEBHOOKS AND INTEGRATIONS PIPING

    DATA TO COMPUTE CLOUDS GETTING STARTED WITH THE CLI
  7. SDKS FOR MOBILE AND WEB DEVELOPMENT myPhoton!.getVariable("temperature", completion: { (result:Any?,

    error:Error?) !-> Void in if let _ = error { print("Failed reading temperature from device") } else { if let temp = result as? NSNumber { print("Room temp is \(temp.stringValue) degrees") } } }) List<ParticleDevice> devices = ParticleCloudSDK.getCloud().getDevices(); for (ParticleDevice device : devices) { if (device.getName().equals("myDevice")) { doSomethingWithMyDevice(device); break; } } var brew = particle.callFunction({ deviceId: 'DEVICE_ID', name: 'brew', argument: 'D0:HIGH', auth: token }); brew.then( (data) !=> console.log(‘Function called:', data), (err) !=> console.log('An error occurred:', err); ); ParticleDevice myDevice = null; List<ParticleDevice> devices = ParticleCloud.SharedCloud.GetDevicesAsync(); foreach (ParticleDevice device in devices) { if (device.Name().equals("myDeviceName")) myDevice = device; }
  8. BUILDING NATIVE MOBILE APPS WITH NATIVESCRIPT + VUE.JS <Slider id="redSlider"

    minValue="0" maxValue="255" v-model="redAmount" @valueChange="onRedChanged" !/> <Slider id="greenSlider" minValue="0" maxValue="255" v-model="greenAmount" @valueChange="onGreenChanged" !/> <Slider id="blueSlider" minValue="0" maxValue="255" v-model="blueAmount" @valueChange="onBlueChanged" !/> <GridLayout columns="100, 115" rows="80"> <Label row="0" col="0" text="Blink Speed" !/> <ListPicker row="0" col="1" :items="blinkSpeeds" v-model="currentBlinkSpeed" @selectedIndexChange="onSpeedChanged" !/> !</GridLayout> <GridLayout columns="100, 115" rows="80"> <Label row="0" col="0" text="Take Control" !/> <Switch row="0" col="1" id="controlRGBLED" v-model="isControlling" @checkedChange="onControlChanged" !/> !</GridLayout> <script> export default { methods: { onRedChanged: function(args) { callParticleAPI('setRed', this.redAmount); }, onGreenChanged: function(args) { callParticleAPI('setGreen', this.greenAmount); }, onBlueChanged: function(args) { callParticleAPI('setBlue', this.blueAmount); }, onSpeedChanged: function(args) { callParticleAPI('setBlinkRate', this.currentBlinkSpeed); }, onControlChanged: function(args) { callParticleAPI('toggleCtrl', this.isControlling); }, onSignalChanged: function(args) { signalDevice(this.isSignaling ? 1 : 0); } } }; !</script> +
  9. USING THE PARTICLE JAVASCRIPT LIBRARY IN BROWSER AND NODE APPS

    const listDevices = token !=> { return new Promise((resolve, reject) !=> { particle .listDevices({ auth: token }) .then(devices !=> resolve(devices), err !=> reject(err)); }); }; const getDevice = (token, id) !=> { return new Promise((resolve, reject) !=> { particle .getDevice({ deviceId: id, auth: token }) .then(device !=> resolve(device)) .catch(err !=> reject(err)); }); }; const handlers = { NumberOfDevicesIntent: function() { let response; const token = this.event.session.user.accessToken; if (token !!=== undefined) { return emitAccountLinkResponse(this); } particleApiUtils .getOnlineDevices(token) .then(devices !=> { const onlineDevicesCount = devices.length; response = `You currently have ${ onlineDevicesCount > 1 ? `${onlineDevicesCount} devices` : `${onlineDevicesCount} device` } online.`; }) .catch(err !=> { response = `This request has failed. Please try again. ${err}`; }) .finally(() !=> { emitResponse(this, response); }); } }; Promise-based
  10. BUILDING WEB AND MOBILE APPS USING WEBHOOKS AND INTEGRATIONS PIPING

    DATA TO COMPUTE CLOUDS GETTING STARTED WITH THE CLI
  11. BUILDING WEB AND MOBILE APPS USING WEBHOOKS AND INTEGRATIONS PIPING

    DATA TO COMPUTE CLOUDS GETTING STARTED WITH THE CLI
  12. USE CASE: INTEGRATING 3RD PARTY TOOLS AND SERVICES Jacuzzi is

    a well-known hot tub manufacturer that sells spas to thousands of consumers and hotels each year. Their Particle-powered connected tub allows service people to remotely monitor and troubleshoot hot tubs using an interface presented to them in Salesforce Service Cloud.
  13. Water quality data sent to Rules Engine Connected Hot Tub

    Jacuzzi service person Serviceperson sees alert, and can remotely troubleshoot tub via Salesforce UI If water becomes too dirty, an alert is sent to Salesforce USE CASE: INTEGRATING 3RD PARTY TOOLS AND SERVICES
  14. PUBLISHING DEVICE DATA TO AZURE IOT CENTRAL #include "AzureIotHubClient.h" #define

    AZURE_CONNECTON_STRING “<STRING HERE>" int callbackDirectMethod(char *method, byte *payload, unsigned int payloadLength) { if (strcmp(method, "readSensors") !== 0) { Particle.publish("iot-central/debug", "Read Sensors from IoT Central!", PRIVATE); readSensors(); } else if (strcmp(method, "toggleLed") !== 0) { Particle.publish("iot-central/debug", "Toggle LED from IoT Central!", PRIVATE); toggleLed(""); } else { return 400; } return 200; } IotHub hub(AZURE_CONNECTON_STRING, NULL, callbackDirectMethod); void createEventPayload(int temp, int humidity, double light) { JsonWriterStatic<256> jw; { JsonWriterAutoObject obj(&jw); jw.insertKeyValue("temp", temp); jw.insertKeyValue("humidity", humidity); jw.insertKeyValue("light", light); if (hub.loop()) { Particle.publish("iot-central/debug", “Sending Env Vals", PRIVATE); jw.insertKeyValue("deviceid", hub.getDeviceId()); } } if (hub.loop()) { hub.publish(jw.getBuffer()); } Particle.publish("env-vals", jw.getBuffer(), PRIVATE); } CONFIGURING & RESPONDING TO COMMANDS SENDING DEVICE TELEMETRY