Code Monkey home page Code Monkey logo

arduino-sdk's Introduction

arduino-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sheraz-janjua

arduino-sdk's Issues

Use ArduinoJson instead of Arduino_JSON for serializing and de-serializing

We used Arduino_JSON in the SDK because of its simplicity and syntax similarity with that of javascript's JSON which makes it easy to understand and kind of consistent for multiple platforms. But I realized that ArduinoJson is better in terms of performance. Plus Arduino_JSON is still in beta stage which can make it vulnerable to bugs.

Device connection listener

We have added two connection listeners i.e. Apollo Connection Listener, Apollo Disconnection Listener which isn't consistent with the JS SDK where there is a single listener called onConnection. So whenever state gets a change, we send CONNECTED or DISCONNECTED in the callback argument.
Secondly, this should be extended to send other events like related to WiFi.

Set event handler after receiving acknowledgement from Grandeur.

Right now, we call subscriptions.on() right as we send subscription request message to Grandeur. The request could get rejected. Therefore, we should call it after we receive acknowledgement from Grandeur. For that, we can add a task which would schedule a function calling subscriptions.on(). This can be done using a lambda function.

But our Callback class doesn't accept a lambda functions as of now. So we need to redesign the Callback to accept lambda functions.

Using Async Duplex

I've heard there's an async version of duplex too which can further remove the need of somethings we are doing, e.g., the update function that the user needs to call in loop() to keep updating the TCP buffer.

Compilation Error for std::Vector

Following error occurs on compiling example 'HelloGrandeur-esp32':

arduino-sdk\src/EventEmitter/EventEmitter.h:14:8:

error: 'vector' in namespace 'std' does not name a template type

std::vector events;

Probably the same with every program.

Shifting error handling into the library

It's in nature of device's duplex connection with the Grandeur Cloud which we can take to our advantage and shift the errors code checking into the library instead of letting the user handle them.

Every function (getSummary, setSumary, getParms, setParms) sends deviceID and some related data to the cloud. Since the deviceID is already validated while the establishment of connection, DEVICE-ID-INVALID error won't occur. The only other error that can occur is SERVER-ERROR which is a server-side error and client has nothing to do with it.

Therefore, we can easily do the these errors code handling in the library and return only the data after stripping off the code and message. This would minimize user's headache and make its development much more seamless.

Setting a device variable only when it changes: Implementing data streams.

Currently, device variables are only updated when the device calls set(), which it has to do in loop() to push updates onto Grandeur, which in most of the cases is redundant data. We can add a function to the SDK that watches a variable, and calls the underlying when an update occurs. Like a stream of data. A variable can be piped to its version on Grandeur.

This looks useful to me. Tell me your thoughts about it.

Compiling error

I have tried compiling the code and it gives following error.
PS: I have installed the libraries as instructed in the email.

Arduino: 1.6.5 (Windows 8.1), Board: "LOLIN(WEMOS) D1 mini Pro, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 16M (14M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

C:\Users\Hasnain\Documents\Arduino\libraries\grandeurcloud-arduino-sdk-master\src\Duplex.cpp:26:18: fatal error: Hash.h: No such file or directory
#include <Hash.h>
^
compilation terminated.
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

deviceID should be received as an argument

In functions like getSummary the deviceID should be received directly in argument instead of first wrapping it in JSON object. That is the way we are receiving deviceID in JS SDK.

Improve structure of device data get/set callback

We can make the structure of data().get() and data().set() callback consistent with data().on() callback.

We can make the structure of data().on() callback as:
callback(const char* path, Var data)

and that of data().get() and data().set() callback as:
callback(const char* code, Var data)

Use would no longer have to use the [] notation of Var other than when representing JSON objects.

Posession of loop() function of the SDK

The loop function practically runs the SDK and makes the asynchronous behavior possible. User has to call it in the loop() of his/her Arduino sketch. It has nothing to do with a project, it's a function very specific to arduino architecture. Everywhere: on JS SDK and Py SDK, Project class provides access of and methods for interacting with the project space on Grandeur. loop isn't one of those.

My suggestion is, we keep Project, Device, Datastore classes pure and free of the architectural differences and move architecture-specific methods to Grandeur class. User would do grandeur.loop() instead.

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.