Git Product home page Git Product logo

ior-arduino's Introduction

IOTClient-Arduino

IOT is taking over world, many electronics device connect together on a network and communicate to each other. I have build app that helps you to connect those microcontroller together. Below are the client details.

Currently it has been tested on: Arduino, Lego Mindstroms EV3 Brick and on a Raspberry PI 3 other tests are being done.

This is git repository for the Arduino client: Before contuning verify that you have ArduinoJson in you arduino library.

Before starting make sure you have required libraries installed in your arduino library path

Include Libraries

#include <LinkedList.h>
#include <IOTClient.h>

For Ethernet Client

#include <Ethernet.h>
#include <SPI.h>

EthernetClient client;

//Inside the setup begin EthernetShield
Ethernet.begin(mac);

For WiFi Client use (remember IOTClient is only checked on the Ethernet, we haven't checked it on WiFi)

#include <WiFi.h>

WiFiClient client;

//Inside a setup begin WiFi
WiFi.begin(ssid,pass);

Define some constants

#define CODE \from\code
#define TO \target\code
	
const char* token = "\paste\subscription\key"

Create IOTClient object

IOTClient it_client(&client, CODE, TO, TOKEN);

Setup Client

it_client.connect(); //Connectes to the IOR Server, returns false if the connection is not made to server. else true 
it_client.setOnReceive(&onReceive);

Last but not the least

it_client.wait4Data(); //Listens if there is a new data from server
Define On Receive Function
void onReceive(const String& message) {
	Serial.println(message);
}
For Sending Message with Metadata

For sending the message we will have 2 Cases:

Case 1: Send only Message
it_client.sendMessage("your message here",NULL); //This will only send a Message to receivers ends
Case 2: Send message with metadata
LinkedList>SyncData*>* list = new LinkedList<SyncData*>();//First create a LinkedList
//Here SyncData is just like a key:value pair
//So create a pointer object of SyncData   
SyncData* data = new SyncData();
data->key = "Here comes the Key";
data->value = "Here comes the Value";
//Add data to the linked list
list->add(data);
//Now send the data
it_client.sendMessage("message",list);
//Remember after sending the message you won't be able to fetch the data for LinkedList  

ior-arduino's People

Contributors

ai-buster avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.