particle-iot/particle-windows-devicesetup

Name: particle-windows-devicesetup

Owner: Particle

Description: Particle Device Setup SDK for Windows apps

Created: 2016-04-19 00:32:42.0

Updated: 2018-01-23 01:23:58.0

Pushed: 2018-01-03 18:40:21.0

Homepage:

Size: 420

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Particle

Particle Device Setup library (Alpha)

license NuGet Version

Introduction

The Particle Device Setup library (Alpha) is meant for integrating the initial setup process of Particle devices in your app. This library will enable you to easily invoke a standalone setup wizard UI for setting up internet-connected products powered by a Particle device (Photon, P0, P1). The setup UI can be easily customized by a customization proxy class, that includes: look & feel, colors, texts and fonts as well as custom brand logos and custom instructional video for your product. There are good defaults in place if you don't set these properties, but you can override the look and feel as needed to suit the rest of your app.

The wireless setup process for the Photon uses very different underlying technology from the Core. Where the Core used TI SmartConfig, the Photon uses what we call “soft AP” - i.e.: the Photon advertises a Wi-Fi network, you join that network from your mobile app to exchange credentials, and then the Photon connects using the Wi-Fi credentials you supplied.

With the Device Setup library, you make one simple call from your app, for example when the user hits a “Setup my device” button, and a whole series of screens then guide the user through the setup process. When the process finishes, the app user is back on the screen where she hit the “Setup my device” button, and your code has been passed an instance of the device she just setup and claimed. Windows Device setup library is implemented as an open-source .NET Portable Class Library. It works well for both C# and VB projects.

Alpha notice

This Library is still under development and is currently released as Alpha and over the next few months may go under considerable changes. Although tested, bugs and issues may be present. Some code might require cleanup. In addition, until version 1.0 is released, we cannot guarantee that API calls will not break from one version to the next. Be sure to consult the Change Log for any breaking changes / additions to the library.

Getting started
Usage

Due to limitations on how string resources are handled in a PCL (Portable Class Library) you will need to inject the resources from the setup library into your app:

You can either do this on app startup, or before you start the soft AP process.

indowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(
peof(Particle.Setup.SetupResources)

You will need to create an instance of the SoftAPSettings class to pass to SoftAP.Start():

And populate the following required properties:

| Value | Meaning | | — | — | | AppFrame | The main application frame | | CompletionPageType | The page to show after completion | | Username | The username of the user if you want it shown | | CurrentDeviceNames | A HashSet of current device names to check against when assigning a name | | OnSoftAPExit | A function of type SoftAPExitEventHandler that is called when the soft AP process exits |

If you are developing an application for Windows Phone, you will need to handle the hardware back buttons.

Define BackPressed EventHandler:

 HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)

Handled = SoftAP.BackButtonPressed();

Add the handler:

wareButtons.BackPressed += HardwareButtons_BackPressed;

And set it to remove on soft AP exit (and make sure to add this to your SoftAPSettings.OnSoftAPExit:

 SoftAPSettings_OnSoftAPExit()

rdwareButtons.BackPressed -= HardwareButtons_BackPressed;

And finally you can call start:

AP.Start(softAPSettings);

When the soft AP process is complete, the static class SoftAP.SoftAPResult will be populated with the results

Result: The result of the process ParticleDevice: The particle device that just went through the soft AP process

Possible result values:

| Value | Meaning | | — | — | | Success | The process completed successfully | | SuccessUnknown | The process completed successfully, but you do not own the device | | SuccessDeviceOffline | The process completed successfully, but is currently offline | | FailureConfigure | The device was unable to be configured |

Internally used direct soft AP commands

The Device Setup library currently also has the internally used class: SoftAPConfig which is an object that enables all basic soft AP commands.

Get device ID
deviceID = await SoftAPConfig.GetDeviceIdAsync();
Get public key
publicKey = await SoftAPConfig.GetPublicKeyAsync();
Get scan AP's
scanAPs = await SoftAPConfig.GetScanAPsAsync();
Get version
version = await SoftAPConfig.GetVersionAsync();
Set claim code
result = await SoftAPConfig.SetClaimCodeAsync(claimCode);
Set configure AP
result = await SoftAPConfig.SetConfigureAPAsync(index, scanAP, password, publicKey);
Set connect AP
result = await SoftAPConfig.SetConnectAPAsync(index);
Installation

You can either download Particle Device Setup library or install using NuGet

PM> Install-Package Particle.Setup

Communication
Maintainers
License

Particle Device Setup library is available under the Apache License 2.0. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.