Skip to content

erosnemesis/ParticleSDK

 
 

Repository files navigation

There is now an offical sdk from Particle Particle Windows Cloud SDK

Build

master develop
Build status Build status

ParticleSDK

.NET SDK for Particle.io (formally spark.io)

Framework Specific Versions

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
NuGet NuGet

Portable Versions

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
NuGet NuGet

Documentation

Tinker App

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

Examples

Connecting to the Cloud

using(var cloud = new ParticleCloud())
{
    var result = await cloud.LoginWithUserAsync("user@email.com", "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
    }
}

Get a list of devices

var result = await cloud.GetDevicesAsync();
if(result.Success)
{
    List<ParticleDevice> list = result.Data;
    foreach(var device in list)
    {
        Console.WriteLine(device.Name);
    }
}

Call a function on a device

    var result = await device.CallFunction("Name", "Parameter");
    if(result.Success)
    {
        Console.WriteLine("Name Fuction Returned: {0}", result.Data);
    }
    else
    {
        // Error while calling function
    }

Get a Variable Value

    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
    }

Not currently implemented

  • 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

About

.NET SDK for Particle.io (formally spark.io)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 96.9%
  • PowerShell 3.1%