Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allthingstalk/csharp-client
[deprecated] [Raspberry Pi Windows 10] C# client library to connect to the AllThingsTalk platform
https://github.com/allthingstalk/csharp-client
deprecated
Last synced: 28 days ago
JSON representation
[deprecated] [Raspberry Pi Windows 10] C# client library to connect to the AllThingsTalk platform
- Host: GitHub
- URL: https://github.com/allthingstalk/csharp-client
- Owner: allthingstalk
- License: apache-2.0
- Created: 2015-01-28T10:18:43.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-23T10:16:52.000Z (over 7 years ago)
- Last Synced: 2025-01-02T19:45:05.423Z (28 days ago)
- Topics: deprecated
- Language: C#
- Homepage: http://maker.allthingstalk.com
- Size: 1.25 MB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
### This library is deprecated
Csharp-client library is deprecated, and will not receive any further updates.
---
# Csharp-client
## Description
C# Client library for connecting internet of things applications to the AllThingsTalk platform
## Features
supports:- creating, updating & deleting devices
- creating & updating assets
- sending and receiving asset values, supported formats:
- json
- csv
- uses events for incomming asset values & commandsDepends on:
- [Newtonsoft.json](https://www.nuget.org/packages/Newtonsoft.Json/) for working with Json data.
- [m2mqtt](https://m2mqtt.codeplex.com/) mqtt library for pub-sub communication.## Installation
There's a nuget package available at: [https://www.nuget.org/packages/att.iot.client/](https://www.nuget.org/packages/att.iot.client/) for easy installation.## Usage
### Full demo app
The following application will create a new device, add 2 assets to it and will wait for an incomming asset command or until you press a key upon which it will send an asset value to the cloud.
The 'MyLogger' object that is used, is a interface implementation that simply writes the text to the console screen (Console.WriteLn)class Program
{
static Device _device;
static MyLogger _logger;private static void Init()
{
//provide a logger object
_logger = new MyLogger();
//create the device object with your account details
_device = new Device("testjan", "5i4duakv2bq", _logger);
_device.DeviceId = "your device id";
_device.ActuatorValue += _device_ActuatorValue;
}static void Main(string[] args)
{
Init();
//update or create the assets on the device.
_device.UpdateAsset("1", "test actuator", "a test actuator", true, "boolean");
//the id of the asset can be string, integer,...
_device.UpdateAsset(2, "test sensor", "a test sensor", false, "boolean");
_device.UpdateAsset(3, "test sensor 2", "a test sensor without type, defaults to string, does not overwrite manual changes on platform", false, null);//wait to continue so that we can send a value from the cloud to the app.
Console.ReadKey();//send a value to the platform
_device.Send(2, "true");
}static void _device_ActuatorValue(object sender, ActuatorData e)
{
_logger.Trace("incomming value found: {0}", e.ToString());//check the actuator for which we received a command
if (e.Asset == 1)
{
//actuators can send simple strings or complex json values.
StringActuatorData data = (StringActuatorData)e;
//do something with the value
if(data.AsBool() == true)
_logger.Trace("actuating sensor");
}
}
}