There is now an offical sdk from Particle Particle Windows Cloud SDK
master | develop |
---|---|
.NET SDK for Particle.io (formally spark.io)
Native Library for UWP/UAP, Windows 8.1, Windows Phone 8.1, .NET 4.5. Using Framework Specific version of HttpClient.
Install-Package ParticleNET.ParticleSDK -Pre
Release | Beta |
---|---|
Portable Library supporting UWP, Win8.1, Windows Phone 8.1, .NET 4.5. Should also work with mono and Xamarin but not tested. Using HttpClient package from Microsoft for consistency.
Install-Package ParticleNET.ParticleSDK.Portable -Pre
Release | Beta |
---|---|
The example app is an implementation of the Tinker App for WP 8.1, Windows 8.1 and Windows 10 found here.
Download Tinker App
Windows Store 8.1
Windows Phone Store 8.1
using(var cloud = new ParticleCloud())
{
var result = await cloud.LoginWithUserAsync("[email protected]", "test");
if(result.Success) // User is logged in
{
// Continue to next step
}
else // User is not logged in
{
// tell the user there not logged in
}
}
var result = await cloud.GetDevicesAsync();
if(result.Success)
{
List<ParticleDevice> list = result.Data;
foreach(var device in list)
{
Console.WriteLine(device.Name);
}
}
var result = await device.CallFunction("Name", "Parameter");
if(result.Success)
{
Console.WriteLine("Name Fuction Returned: {0}", result.Data);
}
else
{
// Error while calling function
}
var result = await device.GetVariableValueAsync("temp");
if(result.Success)
{
var variable = result.Data;
Console.WriteLine("Variable {0} with type {1} has the value {2}", variable.Name, variable.Type, variable.Value);
// Refresh the value with the variable object
var r = await variable.RefreshValueAsync();
if(r.Success)
{
// The value has been updated
Console.WriteLine("Updated Value {0}", variable.Value);
}
else
{
// There was a problem refreshing the value
Console.WriteLine("Error Updating variable value: Error {0} ErrorDescription {1}", r.Error, r.ErrorDescription);
}
}
else
{
// Error while getting variable value
}
- Compiling and flashing files with the cloud
- Flashing a compiled file
- Getting a device directly by its id
- Getting a stream of events
- Getting a stream of events from a device
- Publishing an event