From 0532d94e6194eeb7112738e875039a6d5f477576 Mon Sep 17 00:00:00 2001 From: MA Date: Wed, 9 Mar 2022 14:39:24 +0500 Subject: [PATCH 1/9] V1.0.7 is created --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index d51d5d9..b8b0b89 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Grandeur -version=1.0.6 +version=1.0.7 author=Grandeur Technologies maintainer=Grandeur Technologies sentence=Let your arduinos and ESPs communicate with Grandeur in realtime. From c27942e64b253b4b3068f6ad7be04f361f892795 Mon Sep 17 00:00:00 2001 From: MA Date: Tue, 26 Jul 2022 16:43:26 +0500 Subject: [PATCH 2/9] include issue is resolved --- .../CrossListening-esp32/CrossListening-esp32.ino | 2 +- src/EventEmitter/EventEmitter.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino index daf5c31..d6b2c93 100644 --- a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino +++ b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino @@ -55,7 +55,7 @@ void afterVoltageIsUpdated(const char *code, int voltage); void setup() { - .begin(9600); + Serial.begin(9600); startWiFi(); // This initializes the SDK's configurations and returns reference to your project. project = grandeur.init(apiKey, token); diff --git a/src/EventEmitter/EventEmitter.h b/src/EventEmitter/EventEmitter.h index b1d32f1..ace3a4a 100755 --- a/src/EventEmitter/EventEmitter.h +++ b/src/EventEmitter/EventEmitter.h @@ -1,4 +1,5 @@ #include +#include #include "Listener.h" #ifndef _EVENT_EMITTER_H_ From cf72551ac425ee231ab1476252305f996160c826 Mon Sep 17 00:00:00 2001 From: MA Date: Mon, 26 Jun 2023 20:42:07 +0500 Subject: [PATCH 3/9] "Datastore" functionality is completely removed from the SDK. --- README.md | 151 +----------------- .../Logging/Logging-esp32/Logging-esp32.ino | 131 --------------- .../Logging-esp8266/Logging-esp8266.ino | 125 --------------- .../Searching-esp32/Searching-esp32.ino | 127 --------------- .../Searching-esp8266/Searching-esp8266.ino | 134 ---------------- keywords.txt | 20 +-- library.properties | 4 +- src/Datastore.cpp | 143 ----------------- src/DuplexHandler.cpp | 8 - src/Grandeur.cpp | 5 - src/Grandeur.h | 69 -------- 11 files changed, 14 insertions(+), 903 deletions(-) delete mode 100644 examples/Datastore/Logging/Logging-esp32/Logging-esp32.ino delete mode 100644 examples/Datastore/Logging/Logging-esp8266/Logging-esp8266.ino delete mode 100644 examples/Datastore/Searching/Searching-esp32/Searching-esp32.ino delete mode 100644 examples/Datastore/Searching/Searching-esp8266/Searching-esp8266.ino delete mode 100755 src/Datastore.cpp diff --git a/README.md b/README.md index 8cbdaec..6046b85 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Introducing Grandeur: A backend as a service (Baas) platform for IoT. We have de Grandeur is designed keeping in mind all the challenges a hardware engineer can face in developing and commercializing a smart (IoT) product. And we made available out-of-the-box APIs to help you integrate your devices and apps. -For example, you can use the **Auth API** to create *register* and *login* flows and make sure each user has access to its own data and no one other than the device admin itself should be able to interact with its device. You can store a humongous amount of data in cloud database to analyze and extract intelligent information from it and display useful graphs. Use our **datastore API** for that. You can host your product's website and your web app on Grandeur as well. It's **as simple as running literally a single command**. Also, your hardware device can listen for events and updates from your app, your app can listen for events and updates from your hardware device, and they can communicate with each other in realtime (with a latency of ~200ms). **Devices API** and **Device SDK** come into play here. But in no way would you have to waste your time in mixing and matching the APIs, checking which one works for your use case, and go through a huge learning curve -- like you would do while working with AWS or Google Cloud Platform. All the Grandeur APIs are completely integrated and speed and security is built in. The SDKs are designed around the whole ideology of **seamless integration.** +For example, you can use the **Auth API** to create *register* and *login* flows and make sure each user has access to its own data and no one other than the device admin itself should be able to interact with its device. You can store a humongous amount of data in cloud database to analyze and extract intelligent information from it and display useful graphs. Use our **device streams** for that. You can host your product's website and your web app on Grandeur as well. It's **as simple as running literally a single command**. Also, your hardware device can listen for events and updates from your app, your app can listen for events and updates from your hardware device, and they can communicate with each other in realtime (with a latency of ~200ms). **Devices API** and **Device SDK** come into play here. But in no way would you have to waste your time in mixing and matching the APIs, checking which one works for your use case, and go through a huge learning curve -- like you would do while working with AWS or Google Cloud Platform. All the Grandeur APIs are completely integrated and speed and security is built in. The SDKs are designed around the whole ideology of **seamless integration.** Grandeur is not a regular IoT cloud. It's a complete IoT product development and management platform, designed for production environments. Here's how: @@ -78,15 +78,11 @@ To get a deeper understanding of the core concepts Grandeur is built upon, dive * [onConnection](#onconnection) * [loop](#loop) * [device](#device-function) - * [datastore](#datastore) * [Device](#device-class) * [Data](#data) * [get](#get) * [set](#set) * [on](#on) - * [Datastore](#datastore) - * [insert](#insert) - * [search](#search) * [Enhancements Under Consideration](#enhancements-under-consideration) ## Get Started @@ -110,7 +106,7 @@ When you include `` in your sketch, a global object `grandeur` is cr ### Initialization -Initialization is as simple as calling `grandeur.init()` with your credentials (Project's API Key and Device's Access Token). The SDK uses your API key to select your project, and device ID and access token to limit its scope to only your device's data. It then returns a `Project` object which exposes other subclasses like `Device` and `Datastore`, and you can go programming your device from there. +Initialization is as simple as calling `grandeur.init()` with your credentials (Project's API Key and Device's Access Token). The SDK uses your API key to select your project, and device ID and access token to limit its scope to only your device's data. It then returns a `Project` object which exposes other subclasses like `Device`, and you can go programming your device from there. ```cpp #include @@ -672,7 +668,7 @@ To resolve the energy efficiency issue of these old ACs, you decided to build an That's where the problem arose. You are a hardware startup, after all, that builds amazing electronics technology. But here you got to deal with a few more things as well. You have to build your app and figure out how to establish its communication with your hardware. You may decide to hire more engineers. But do you know how much of them will you have to hire? To give you a perspective, you generally need 8+ engineers just to do the server-end, like one to figure out your networking, one to design and manage your database, one to develop your API (the interface layer between your users and devices), about four for building your SDKs (one for each platform android, ios, web, and hardware) and then when you start scaling up a bit, one DevOps engineer. This makes it a package of $8000+ just to figure out the backend of your system and you haven't even validated your product yet. This turns out exhausting for your business. You have hit a concrete wall with no idea what to do about it. -Then one day the sun of fate shown. You came across a platform that goes by the name of Grandeur. You went through its [website][Grandeur Technologies] and discovered a perfectly fitting solution for all your headaches. You wanted a solution for authentication of your users, it has the Auth feature in it. You needed online file storage to store maybe the profile pictures of your users and other stuff, it comes with a storage builtin. You were in dire need of a scalable out-of-the-box database to store power consumption logs of your device to show your users graphs on their monthly/yearly savings, it provides a cloud datastore service. And the most important of these all, you needed a realtime communication bridge between your hardware and your apps, THANK GOD, its SDKs are available for all the stacks including Arduino, web, and mobile (both android and ios). +Then one day the sun of fate shown. You came across a platform that goes by the name of Grandeur. You went through its [website][Grandeur Technologies] and discovered a perfectly fitting solution for all your headaches. You wanted a solution for authentication of your users, it has the Auth feature in it. You needed online file storage to store maybe the profile pictures of your users and other stuff, it comes with a storage builtin. You were in dire need of a scalable out-of-the-box database to store power consumption logs of your device to show your users graphs on their monthly/yearly savings, it provides a cloud data storage service. And the most important of these all, you needed a realtime communication bridge between your hardware and your apps, THANK GOD, its SDKs are available for all the stacks including Arduino, web, and mobile (both android and ios). So here you are giving it a shot. You simply [registered for the platform][Grandeur], created your first project, downloaded their SDKs and started connecting your devices and apps through Grandeur. You didn't even have to worry about the security of your users and devices, because the data on Grandeur is protected under standard security protocols. Each user and device in a project is limited in its scope. All you had to worry about was designing your product core and develop your business logic. And in a matter of weeks, your product was out in people's hands, your apps live on app stores. People loved what you built and you were getting live feedback on it. You could see how many people have paired with your devices. You made an early entry into the market and now adding a dent to the universe. @@ -684,7 +680,7 @@ In this subsection, we will explore the Grandeur platform in detail and see how ### Project -A project is the first thing you need to create to start working with Grandeur. A project is like a namespace, a completely isolated network of users and devices, along with separate file storage and a separate datastore. While you can create an unlimited number of projects, but no two projects can interact or share anything with one other. +A project is the first thing you need to create to start working with Grandeur. A project is like a namespace, a completely isolated network of users and devices, along with a separate data storage. While you can create an unlimited number of projects, but no two projects can interact or share anything with one other. Each project is identified by a digital signature that we call the API key, just as your identification card or social security number identifies you as a citizen. To connect your apps or hardware to your project's network, this is what you need to provide to the SDKs. The API key is sent with every request to Grandeur and this is what defines the project of the request. Check out the [SDK][SDK] section to read more about it. @@ -694,7 +690,7 @@ Each project is identified by a digital signature that we call the API key, just Grandeur is the API that exposes Grandeur to the outside world. Our SDKs utilize this API and map each functionality to a function. We have tried our best to make the integration of our SDKs into your codebase simple. For example, while developing your web app, you simply need to drop in the link of JS SDK CDN in your codebase and you are done. We have developed our SDKs for each platform in coherence with each other so you could work and collaborate everywhere seamlessly. -This is how they work: In every SDK, there is a global object aka. `grandeur`. You can initialize your configurations (API Key and a couple of more stuff in case of hardware SDK) by calling `grandeur.init()`. This returns you a reference to your whole project (in case of your app) or just to your device (in case of hardware because hardware scope is limited to the device itself). In **JS SDK**, you can interact with the authentication API, the device API, the file storage and the datastore API. In the case of **Arduino SDK** your scope is limited to just the device's namespace. Check out the [Authentication and Access][Authentication and Access] section to get more insight into how scope varies across the different platforms (app and hardware). +This is how they work: In every SDK, there is a global object aka. `grandeur`. You can initialize your configurations (API Key and a couple of more stuff in case of hardware SDK) by calling `grandeur.init()`. This returns you a reference to your whole project (in case of your app) or just to your device (in case of hardware because hardware scope is limited to the device itself). In **JS SDK**, you can interact with the authentication API and the devices API. In the case of **Arduino SDK** your scope is limited to just the device's namespace. Check out the [Authentication and Access][Authentication and Access] section to get more insight into how scope varies across the different platforms (app and hardware). ### User and Administrator @@ -754,7 +750,7 @@ Previously, we have discussed in depth which entity (administrator, user, device You (as an administrator) create a project and therefore have global access to everything. You can access and manage your projects and their resources using the dashboard application. You want your users and devices to have limited access to your project's resources based on their scopes which you achieve by using our SDKs in your apps and hardware. Your project's API Key delegates your project's access to the SDKs and access tokens allow and limit, at the same time, this access to user and device scopes. -The user scope is wider than the device scope. A user can access its profile, the registry of the devices it's paired to, the files in the project's storage and the data in the project's datastore. When a user logs in, an Auth token is returned. This token along with the API Key, being sent with every request, is what validates the authority of the request. +The user scope is wider than the device scope. A user can access its profile, the registry of the devices it's paired to and all of their data. When a user logs in, an Auth token is returned. This token along with the API Key, being sent with every request, is what validates the authority of the request. The device scope is limited to the device's namespace in the device registry. When a user pairs with a device, an access token is returned for the device. This access token along with the API Key is what authenticates the device's connection to Grandeur. @@ -770,7 +766,7 @@ In the **Arduino SDK**, we only use the realtime channel. A device cannot establ ### Allowed Origins -This is another amazing topic and somehow related to access delegation in the end. As mentioned in the sections above that you can interact with your project's namespace through the JS SDK by initializing grandeur with your API key. This returns an object referring to your project which can be used to interact with its resources including its devices, datastore, and files storage. Putting this much responsibility on just the API key poses a security threat particularly in case of web apps as API Key can easily be stolen. Even though a user needs to log in first before making any request to the cloud, a hacker with having your API key can still cause some serious damage. For example, Registering bogus users to your project or creating a copycat site on your name for phishing to name a few. That's where cross-origin request sharing (CORS) policies come to play. +This is another amazing topic and somehow related to access delegation in the end. As mentioned in the sections above that you can interact with your project's namespace through the JS SDK by initializing grandeur with your API key. This returns an object referring to your project which can be used to interact with its devices. Putting this much responsibility on just the API key poses a security threat particularly in case of web apps as API Key can easily be stolen. Even though a user needs to log in first before making any request to the cloud, a hacker with having your API key can still cause some serious damage. For example, Registering bogus users to your project or creating a copycat site on your name for phishing to name a few. That's where cross-origin request sharing (CORS) policies come to play. So to allow a web app to interact with your project using the Web SDK, you first need to whitelist the domain name your web app uses via the settings page in the dashboard. You cannot even send a request from your localhost without first whitelisting it. @@ -816,7 +812,7 @@ void setup() { ## Project -Project is the main class of the SDK. When your device connects with Grandeur, this class represents your grandeur project, from the device's perspective — there are only two resources your device can interact with: **device** and **datastore**, which are represented by their respective classes. +Project is the main class of the SDK. When your device connects with Grandeur, this class represents your grandeur project, from the device's perspective — there is only one resource your device can interact with: **device**, which is represented by its respective classes. Project class exposes the following methods: @@ -942,26 +938,6 @@ void setup() { // Gets the object of Device class. ``` -### datastore - -> datastore (void) : returns _Grandeur::Project::Datastore_ - -This method returns a reference to object of the **Datastore** class. Datastore class exposes the functions of the datastore API which handles your queries to your project's datastore like: logging device variables to the cloud datastore, searching for data, etc. - -#### Example - -```cpp -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; -void setup() { - myProject = grandeur.init(YourApiKey, YourToken); - myDatastore = myProject.datastore(); -} - -// **RESULT** -// Gets the object of Datastore class. -``` - ## Device Device class gives you the functions to interact with your device data. Its `data` function returns the object of `Data` class that gives you the functions to get, set, and subscribe to the device's data variables. Subscribe means if you update this device's data variables from anywhere other than this device itself, this device will get the update. This is great for realtime switching ON/OFF of your device remotely from an app or changing voltage of its pins for example. @@ -1136,117 +1112,6 @@ void loop() { You can subscribe to all device data variables with the `path`-less `on` function overload. -## Datastore - -Datastore class gives you the functions to store and search for data in Grandeur datastore which a highly scalable database where you can log data points and retrieve them later to plot trend or device health graphs. Read about Datastore [here](https://www.hackster.io/grandeurtech/data-persistence-in-iot-with-grander-fd09ee). - -Datastore class exposes the following functions: - -### insert - -> insert (documents: _Var_, callback: _Callback_) : returns _void_ - -This method inserts documents into datastore. - -#### Parameters - -| Name | Type | Description | -|-------------|--------------|--------------------------------------------------------------------| -| documents | _Var_ | An array of documents (_Var_ s) to be inserted into the datastore. | -| callback | _Callback_ | A function to be called when insertion of documents completes. | - -#### Example - -```cpp -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; - -void insertCallback(Var insertionResult) { - // This method just prints if the insertion is successful or not. - if(insertionResult["code"] == "DATASTORE-DOCUMENTS-INSERTED") Serial.println("Insertion successful."); - else Serial.println("Insertion Failed."); -} - -void setup() { - myProject = grandeur.init(YourApiKey, YourToken); - myDatastore = myProject.datastore(YourDeviceID); -} - -void loop() { - // This inserts a document containing voltage and current readings in datastore on every loop. - Var docs; - // Adding voltage and current readings to the first document of docs array. - // In JSON, the docs array looks like this: - // [{"voltage": analogRead(A0), "current": analogRead(A1)}] - docs[0]["voltage"] = analogRead(A0); - docs[0]["current"] = analogRead(A1); - // Inserting the docs in datastore. insertCallback() will be called when insertion process - // completes. - myDatastore.insert(docs, insertCallback); - - if(WiFiIsConnected) myProject.loop(); -} - -// **RESULT** -// Prints "Insertion successful." if documents are inserted. If an error occurred, it prints -// "Insertion Failed." -``` - -### search - -> search (filter: _Var_, projection: _Var_, pageNumber: _int_, callback: _Callback_) : returns _void_ - -This method searches for documents in datastore based on the `filter` supplied. `Filter` describes what documents to return and `projection` describes what fields to return in those documents. Documents are returned in pages and each page is **20 documents** in size. This is what the `pageNumber` is for. You'll get first page by specifying the `pageNumber` to 0 and 1 for second page. and so on. - -#### Parameters - -| Name | Type | Description | -|-------------|--------------|----------------------------------------------------------------------------------------| -| filter | _Var_ | A document describing the conditions that the documents to be returned are to satisfy. | -| projection | _Var_ | A document that describes what fields to return. | -| pageNumber | _int_ | Number of the page to return. | -| callback | _Callback_ | A function to be called when documents are completed. | - -#### Example - -```cpp -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; - -void searchCallback(Var searchResult) { - // This method just prints the documents if the search is successful. - if(searchResult["code"] == "DATASTORE-DOCUMENTS-FETCHED") { - Serial.print("Documents fetched from Grandeur: "); - Serial.println(searchResult["documents"].length()); - // Printing all the fetched documents. - for(int i = 0; i < searchResult["documents"].length(); i++) { - Serial.println(JSON.stringify(searchResult["documents"][i]).c_str()); - // Just to keep the watchdog timer from tripping. - delay(1); - } - Serial.println(""); - return; - } - Serial.println("Search Failed."); -} - -void setup() { - myProject = grandeur.init(YourApiKey, YourToken); - myDatastore = myProject.datastore(YourDeviceID); -} - -void loop() { - // This fetches 1st page of all the documents stored in the datastore. - myDatastore.collection("myCollectionName").search({}, {}, 0, searchCallback); - - if(WiFiIsConnected) myProject.loop(); -} - -// **RESULT** -// Prints the documents if search is successful. If an error occurred, it prints -// "Search Failed." -``` - ## Enhancements Under Consideration: Here are some enhancements that we are considering to implement in the SDK. They have their corresponding issues as well. If you can relate to any one of these and would like to fast forward its implementation, just comment +1 on its issue. This would be a feedback for us to set priorities in a user-centered way. Thank you 👇 diff --git a/examples/Datastore/Logging/Logging-esp32/Logging-esp32.ino b/examples/Datastore/Logging/Logging-esp32/Logging-esp32.ino deleted file mode 100644 index dabf7dd..0000000 --- a/examples/Datastore/Logging/Logging-esp32/Logging-esp32.ino +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file Logging-esp32.ino - * @date 21.06.2020 - * @author Grandeur Technologies - * - * Copyright (c) 2019 Grandeur Technologies LLP. All rights reserved. - * This file is part of the Arduino SDK for Grandeur. - * - * Grandeur.h is used for device's communication to Grandeur. - * WiFi.h is used for handling device's WiFi. - * - * This example illustrates the insertion of data into the datastore. - * It would be useful in logging data on the cloud to visualize it in form of tables or graphs. -*/ - -#include -#include - -// Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String token = "YOUR-ACCESS-TOKEN"; -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; - -// Declaring and initializing other variables -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; -int statePin = 4; -unsigned long current = millis(); - -// Function prototypes -void WiFiEventCallback(WiFiEvent_t event); -void setupWiFi(void); -void connectionCallback(bool status); -void insertCallback(const char *code); - -void setup() -{ - Serial.begin(9600); - // This sets up the device WiFi. - setupWiFi(); - // This initializes the SDK's configurations and returns a reference to my project on Grandeur. - myProject = grandeur.init(apiKey, token); - // Getting object of Datastore class. - myDatastore = myProject.datastore(); - // This schedules the connectionCallback() function to be called when connection with Grandeur - // is made/broken. - myProject.onConnection(connectionCallback); -} - -void loop() -{ - if (myProject.isConnected()) - { - if (millis() - current >= 5000) - { - // This if-condition makes sure that the code inside this block runs only after - // every five seconds. - Var logs; - logs[0]["voltage"] = analogRead(A0); - myDatastore.collection("logs").insert(logs, insertCallback); - // This updates the millis counter for - // the five seconds scheduler. - current = millis(); - } - } - - // The SDK only runs when the WiFi is connected. - if (WiFi.status() == WL_CONNECTED) - project.loop(); -} - -void WiFiEventCallback(WiFiEvent_t event) -{ - switch (event) - { - case SYSTEM_EVENT_STA_GOT_IP: - // This runs when the device connects with WiFi. - Serial.printf("\nDevice has successfully connected to WiFi. Its IP Address is: %s\n", - WiFi.localIP().toString().c_str()); - break; - case SYSTEM_EVENT_STA_DISCONNECTED: - // This runs when the device disconnects with WiFi. - Serial.println("Device is disconnected from WiFi."); - break; - default: - break; - } -} - -void setupWiFi(void) -{ - // Disconnecting WiFi if it"s already connected - WiFi.disconnect(); - // Setting it to Station mode which basically scans for nearby WiFi routers - WiFi.mode(WIFI_STA); - // Setting WiFi event handler - WiFi.onEvent(WiFiEventCallback); - // Begin connecting to WiFi - WiFi.begin(ssid, passphrase); - Serial.printf("\nDevice is connecting to WiFi using SSID %s and Passphrase %s.\n", ssid, passphrase); -} - -void connectionCallback(bool status) -{ - switch (status) - { - case CONNECTED: - // On successful connection with Grandeur, we initialize the device's *state*. - // To do that, we set the *state pin* to the value of *state* from Grandeur. - Serial.println("Device is connected with Grandeur."); - Serial.println("Logging voltage to Grandeur..."); - break; - case DISCONNECTED: - Serial.println("Device's connection with Grandeur is broken."); - break; - } -} - -void insertCallback(const char *code) -{ - // This function prints if the logs were successfully inserted into the datastore or not. - if (strcmp(code, "DATASTORE-DOCUMENTS-INSERTED") == 0) - { - Serial.printf("Voltage is successfully logged to Grandeur."); - return; - } - // If insertion is not successful. - Serial.println("Failed to log voltage"); - return; -} \ No newline at end of file diff --git a/examples/Datastore/Logging/Logging-esp8266/Logging-esp8266.ino b/examples/Datastore/Logging/Logging-esp8266/Logging-esp8266.ino deleted file mode 100644 index f7dee4b..0000000 --- a/examples/Datastore/Logging/Logging-esp8266/Logging-esp8266.ino +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file Logging-esp8266.ino - * @date 21.06.2020 - * @author Grandeur Technologies - * - * Copyright (c) 2019 Grandeur Technologies LLP. All rights reserved. - * This file is part of the Arduino SDK for Grandeur. - * - * Grandeur.h is used for device's communication to Grandeur. - * ESP8266WiFi.h is used for handling device's WiFi. - * - * This example illustrates the insertion of data into the datastore. - * It would be useful in logging data on the cloud to visualize it in form of tables or graphs. -*/ - -#include -#include - -// Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; - -// Declaring and initializing other variables -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; -WiFiEventHandler onWiFiConnectedHandler; -WiFiEventHandler onWiFiDisconnectedHandler; -int statePin = D0; -unsigned long current = millis(); - -// Function prototypes -void setupWiFi(void); -void connectionCallback(bool status); -void insertCallback(const char *code); - -void setup() -{ - Serial.begin(9600); - // This sets up the device WiFi. - setupWiFi(); - // This initializes the SDK's configurations and returns a reference to my project on Grandeur. - myProject = grandeur.init(apiKey, token); - // Getting object of Datastore class. - myDatastore = myProject.datastore(); - // This schedules the connectionCallback() function to be called when connection with Grandeur - // is made/broken. - myProject.onConnection(connectionCallback); -} - -void loop() -{ - if (myProject.isConnected()) - { - if (millis() - current >= 5000) - { - // This if-condition makes sure that the code inside this block runs only after - // every five seconds. - Var logs; - logs[0]["voltage"] = analogRead(A0); - myDatastore.collection("logs").insert(logs, insertCallback); - // This updates the millis counter for - // the five seconds scheduler. - current = millis(); - } - } - - // The SDK only runs when the WiFi is connected. - if (WiFi.status() == WL_CONNECTED) - project.loop(); -} - -void setupWiFi(void) -{ - // Disconnecting WiFi if it"s already connected - WiFi.disconnect(); - // Setting it to Station mode which basically scans for nearby WiFi routers - WiFi.mode(WIFI_STA); - // Setting WiFi event handlers - onWiFiConnectedHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP &event) - { - // This runs when the device connects with WiFi. - Serial.printf("\nDevice has successfully connected to WiFi. Its IP Address is: %s\n", - WiFi.localIP().toString().c_str()); - }); - onWiFiDisconnectedHandler = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected &event) - { - // This runs when the device disconnects with WiFi. - Serial.println("Device is disconnected from WiFi."); - }); - // Begin connecting to WiFi - WiFi.begin(ssid, passphrase); - Serial.printf("\nDevice is connecting to WiFi using SSID %s and Passphrase %s.\n", ssid, passphrase); -} - -void connectionCallback(bool status) -{ - switch (status) - { - case CONNECTED: - // On successful connection with Grandeur, we initialize the device's *state*. - // To do that, we set the *state pin* to the value of *state* from Grandeur. - Serial.println("Device is connected with Grandeur."); - Serial.println("Logging voltage to Grandeur..."); - break; - case DISCONNECTED: - Serial.println("Device's connection with Grandeur is broken."); - break; - } -} - -void insertCallback(const char *code) -{ - // This function prints if the logs were successfully inserted into the datastore or not. - if (strcmp(code, "DATASTORE-DOCUMENTS-INSERTED") == 0) - { - Serial.printf("Voltage is successfully logged to Grandeur.\n"); - return; - } - // If insertion is not successful. - Serial.println("Failed to log voltage"); - return; -} \ No newline at end of file diff --git a/examples/Datastore/Searching/Searching-esp32/Searching-esp32.ino b/examples/Datastore/Searching/Searching-esp32/Searching-esp32.ino deleted file mode 100644 index 4cb6c26..0000000 --- a/examples/Datastore/Searching/Searching-esp32/Searching-esp32.ino +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file Searching-esp32.ino - * @date 21.06.2020 - * @author Grandeur Technologies - * - * Copyright (c) 2019 Grandeur Technologies LLP. All rights reserved. - * This file is part of the Arduino SDK for Grandeur. - * - * Grandeur.h is used for device's communication to Grandeur. - * WiFi.h is used for handling device's WiFi. - * - * This example illustrates the finding documents in datastore. - * It would be useful in setting device to a previous state or just displaying the data on an LCD. -*/ - -#include -#include - -// Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String token = "YOUR-ACCESS-TOKEN"; -const char* ssid = "YOUR-WIFI-SSID"; -const char* passphrase = "YOUR-WIFI-PASSWORD"; - -// Declaring and initializing other variables -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; -int statePin = 4; -unsigned long current = millis(); - -// Function prototypes -void WiFiEventCallback(WiFiEvent_t event); -void setupWiFi(void); -void connectionCallback(bool status); -void searchCallback(const char* code, Var result); - -void setup() { - Serial.begin(9600); - // This sets up the device WiFi. - setupWiFi(); - // This initializes the SDK's configurations and returns a reference to my project on Grandeur. - myProject = grandeur.init(apiKey, token); - // Getting object of Datastore class. - myDatastore = myProject.datastore(); - // This schedules the connectionCallback() function to be called when connection with Grandeur - // is made/broken. - myProject.onConnection(connectionCallback); -} - -void loop() { - if(myProject.isConnected()) { - if(millis() - current >= 5000) { - // This if-condition makes sure that the code inside this block runs only after - // every five seconds. - // This fetches 1st page of all the documents stored in the datastore. - Var filter; - filter["voltage"]["$gt"] = 1; - myDatastore.collection("logs").search(filter, {}, 0, searchCallback); - // This updates the millis counter for - // the five seconds scheduler. - current = millis(); - } - } - - // The SDK only runs when the WiFi is connected. - if(WiFi.status() == WL_CONNECTED) project.loop(); -} - -void WiFiEventCallback(WiFiEvent_t event) { - switch(event) { - case SYSTEM_EVENT_STA_GOT_IP: - // This runs when the device connects with WiFi. - Serial.printf("\nDevice has successfully connected to WiFi. Its IP Address is: %s\n", - WiFi.localIP().toString().c_str()); - break; - case SYSTEM_EVENT_STA_DISCONNECTED: - // This runs when the device disconnects with WiFi. - Serial.println("Device is disconnected from WiFi."); - break; - default: break; - } -} - -void setupWiFi(void) { - // Disconnecting WiFi if it"s already connected - WiFi.disconnect(); - // Setting it to Station mode which basically scans for nearby WiFi routers - WiFi.mode(WIFI_STA); - // Setting WiFi event handlers - WiFi.onEvent(WiFiEventCallback); - // Begin connecting to WiFi - WiFi.begin(ssid, passphrase); - Serial.printf("\nDevice is connecting to WiFi using SSID %s and Passphrase %s.\n", ssid, passphrase); -} - -void connectionCallback(bool status) { - switch(status) { - case CONNECTED: - // On successful connection with Grandeur, we initialize the device's *state*. - // To do that, we set the *state pin* to the value of *state* from Grandeur. - Serial.println("Device is connected with Grandeur."); - Serial.println("Logging voltage to Grandeur..."); - break; - case DISCONNECTED: - Serial.println("Device's connection with Grandeur is broken."); - break; - } -} - -void searchCallback(const char* code, Var result) { - // This function prints if the datastore search for the docs was successfully or not. - if(searchResult["code"] == "DATASTORE-DOCUMENTS-FETCHED") { - Serial.print("Documents fetched from Grandeur: "); - Serial.println(searchResult["documents"].length()); - // Printing all the fetched documents. - for(int i = 0; i < searchResult["documents"].length(); i++) { - Serial.println(JSON.stringify(searchResult["documents"][i]).c_str()); - // Just to keep the watchdog timer from tripping. - delay(1); - } - Serial.println(""); - return; - } - // If search is not successful. - Serial.println("Failed to fetch documents."); - return; -} diff --git a/examples/Datastore/Searching/Searching-esp8266/Searching-esp8266.ino b/examples/Datastore/Searching/Searching-esp8266/Searching-esp8266.ino deleted file mode 100644 index 30ff895..0000000 --- a/examples/Datastore/Searching/Searching-esp8266/Searching-esp8266.ino +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file Searching-esp8266.ino - * @date 21.06.2020 - * @author Grandeur Technologies - * - * Copyright (c) 2019 Grandeur Technologies LLP. All rights reserved. - * This file is part of the Arduino SDK for Grandeur. - * - * Grandeur.h is used for device's communication to Grandeur. - * ESP8266WiFi.h is used for handling device's WiFi. - * - * This example illustrates the insertion of data into the datastore. - * It would be useful in logging data on the cloud to visualize it in form of tables or graphs. -*/ - -#include -#include - -// Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String token = "YOUR-ACCESS-TOKEN"; -String ssid = "YOUR-WIFI-SSID"; -String passphrase = "YOUR-WIFI-PASSWORD"; - -// Declaring and initializing other variables -Grandeur::Project myProject; -Grandeur::Project::Datastore myDatastore; -WiFiEventHandler onWiFiConnectedHandler; -WiFiEventHandler onWiFiDisconnectedHandler; -int statePin = D0; -unsigned long current = millis(); - -// Function prototypes -void setupWiFi(void); -void connectionCallback(bool status); -void searchCallback(const char *code, Var result); - -void setup() -{ - Serial.begin(9600); - // This sets up the device WiFi. - setupWiFi(); - // This initializes the SDK's configurations and returns a reference to my project on Grandeur. - myProject = grandeur.init(apiKey, token); - // Getting object of Datastore class. - myDatastore = myProject.datastore(); - // This schedules the connectionCallback() function to be called when connection with Grandeur - // is made/broken. - myProject.onConnection(connectionCallback); -} - -void loop() -{ - if (myProject.isConnected()) - { - if (millis() - current >= 5000) - { - // This if-condition makes sure that the code inside this block runs only after - // every five seconds. - // This fetches 1st page of all the documents stored in the datastore. - myDatastore.collection("logs").search({}, {}, 0, searchCallback); - // This updates the millis counter for - // the five seconds scheduler. - current = millis(); - } - } - - // The SDK only runs when the WiFi is connected. - if(WiFi.status() == WL_CONNECTED) project.loop(); -} - -void setupWiFi(void) -{ - // Disconnecting WiFi if it"s already connected - WiFi.disconnect(); - // Setting it to Station mode which basically scans for nearby WiFi routers - WiFi.mode(WIFI_STA); - // Setting WiFi event handlers - onWiFiConnectedHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP &event) - { - // This runs when the device connects with WiFi. - Serial.printf("\nDevice has successfully connected to WiFi. Its IP Address is: %s\n", - WiFi.localIP().toString().c_str()); - }); - onWiFiDisconnectedHandler = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected &event) - { - // This runs when the device disconnects with WiFi. - Serial.println("Device is disconnected from WiFi."); - }); - // Begin connecting to WiFi - WiFi.begin(ssid, passphrase); - Serial.printf("\nDevice is connecting to WiFi using SSID %s and Passphrase %s.\n", ssid, passphrase); -} - -void connectionCallback(bool status) -{ - switch (status) - { - case CONNECTED: - // On successful connection with Grandeur, we initialize the device's *state*. - // To do that, we set the *state pin* to the value of *state* from Grandeur. - Serial.println("Device is connected with Grandeur."); - Serial.println("Searching documents on Grandeur..."); - break; - case DISCONNECTED: - Serial.println("Device's connection with Grandeur is broken."); - break; - } -} - -void searchCallback(const char *code, Var result) -{ - // This function prints if the datastore search for the docs was successfully or not. - if (strcmp(code, "DATASTORE-DOCUMENTS-FETCHED") == 0) - { - Serial.print("Total number of documents that matched the query: "); - Serial.println(result["nDocuments"]); - Serial.print("Number of documents fetched: "); // Will always be 20 if nDocuments > 20 - Serial.println(result["documents"].length()); - Serial.println("------------------------DOCUMENTS------------------------"); - // Printing all the fetched documents. - for (int i = 0; i < result["documents"].length(); i++) - { - Serial.println(JSON.stringify(result["documents"][i]).c_str()); - // Just to keep the watchdog timer from tripping. - delay(1); - } - Serial.println("---------------------------------------------------------"); - return; - } - // If search is not successful. - Serial.println("Failed to fetch documents."); - return; -} \ No newline at end of file diff --git a/keywords.txt b/keywords.txt index 9c75cfc..1152b6f 100644 --- a/keywords.txt +++ b/keywords.txt @@ -7,12 +7,11 @@ Grandeur KEYWORD3 grandeur KEYWORD3 Project KEYWORD3 -Datastore KEYWORD3 Device KEYWORD3 -Data KEYWORD3 +Data KEYWORD3 ####################################### -# Datatypes +# Datatypes ####################################### Callback KEYWORD1 @@ -26,22 +25,11 @@ onConnection KEYWORD2 isConnected KEYWORD2 parse KEYWORD2 stringify KEYWORD2 -device KEYWORD2 -datastore KEYWORD2 +device KEYWORD2 loop KEYWORD2 get KEYWORD2 set KEYWORD2 -collection KEYWORD2 -insert KEYWORD2 -remove KEYWORD2 -update KEYWORD2 -search KEYWORD2 -pipeline KEYWORD2 -match KEYWORD2 -project KEYWORD2 -group KEYWORD2 -sort KEYWORD2 -execute KEYWORD2 +on KEYWORD2 ####################################### # Constants diff --git a/library.properties b/library.properties index b8b0b89..e0f73b2 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=Grandeur version=1.0.7 author=Grandeur Technologies -maintainer=Grandeur Technologies +maintainer=Grandeur Technologies sentence=Let your arduinos and ESPs communicate with Grandeur in realtime. -paragraph=This handles your realtime connection with Grandeur and exposes devices and datastore APIs. Devices API lets you get, set, and subscribe to device variables. And datastore API lets you query your datastore which is a highly available and scalable NOSQL database for IoT. Visit https://grandeur.tech for more details. +paragraph=This handles your realtime connection with Grandeur and exposes the device API. Device API lets you get, set, and subscribe to device variables. Visit https://grandeur.dev for more details. category=Communication url=https://github.com/grandeurtech/arduino-sdk architectures=* diff --git a/src/Datastore.cpp b/src/Datastore.cpp deleted file mode 100755 index b939894..0000000 --- a/src/Datastore.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file Datastore.cpp - * @date 20.06.2020 - * @author Grandeur Technologies - * - * Copyright (c) 2019 Grandeur Technologies LLP. All rights reserved. - * This file is part of the Arduino SDK for Grandeur. - * - */ - -// Including headers -#include "Grandeur.h" - -Grandeur::Project::Datastore::Datastore() {} - -Grandeur::Project::Datastore::Datastore(DuplexHandler* duplexHandler) : _duplex(duplexHandler) {} - -Grandeur::Project::Datastore::Collection Grandeur::Project::Datastore::collection(String name) { - // Return a reference to collection object - return Collection(name, _duplex); -} - -Grandeur::Project::Datastore::Collection::Collection(String name, DuplexHandler* duplexHandler) - : _duplex(duplexHandler), _name(name) {} - -void Grandeur::Project::Datastore::Collection::insert(Var documents, Callback inserted) { - // Insert documents to datastore - Var oPayload; - // Append collection name and documents - oPayload["collection"] = _name; - oPayload["documents"] = documents; - - // Send request to server - _duplex->send("/datastore/insert", oPayload, inserted); -} - -void Grandeur::Project::Datastore::Collection::remove(Var filter, Callback removed) { - // Remove documents from datastore - Var oPayload; - // Append collection name and filter - oPayload["collection"] = _name; - oPayload["filter"] = filter; - - // Send request to server - _duplex->send("/datastore/delete", oPayload, removed); -} - -void Grandeur::Project::Datastore::Collection::update(Var filter, Var update, Callback updated) { - // Update document from datastore - Var oPayload; - // Append collection name, filter and update - oPayload["collection"] = _name; - oPayload["filter"] = filter; - - // Send request to server - _duplex->send("/datastore/update", oPayload, updated); -} - -void Grandeur::Project::Datastore::Collection::search(Var filter, Var projection, int nPage, Callback searched) { - // Basically it will use pipeline - Pipeline searchPipeline = Pipeline(_name, {}, _duplex).match(filter); - - // Add project stage if provided - if(projection == undefined); - else { - searchPipeline = searchPipeline.project(projection); - } - - // Execute the pipeline - return searchPipeline.execute(nPage, searched); -} - -Grandeur::Project::Datastore::Collection::Pipeline Grandeur::Project::Datastore::Collection::pipeline(void) { - // Return a reference to pipeline - return Pipeline(_name, undefined, _duplex); -} - -Grandeur::Project::Datastore::Collection::Pipeline::Pipeline( - String collection, - Var query, - DuplexHandler* duplexHandler -) : _duplex(duplexHandler), _collection(collection), _query(query) {} - -Grandeur::Project::Datastore::Collection::Pipeline Grandeur::Project::Datastore::Collection::Pipeline::match(Var filter) { - // Add match stage to the pipeline - int stage = _query.length() + 1; - - // Add type and filter - _query[stage]["type"] = "match"; - _query[stage]["filter"] = filter; - - // Return reference to pipeline to basically help in chaining - return Pipeline(_collection, _query, _duplex); -} - -Grandeur::Project::Datastore::Collection::Pipeline Grandeur::Project::Datastore::Collection::Pipeline::project(Var specs) { - // Add project stage to the pipeline - int stage = _query.length() + 1; - - // Add type and specs - _query[stage]["type"] = "match"; - _query[stage]["specs"] = specs; - - // Return reference to pipeline to basically help in chaining - return Pipeline(_collection, _query, _duplex); -} - -Grandeur::Project::Datastore::Collection::Pipeline Grandeur::Project::Datastore::Collection::Pipeline::group(Var condition, Var fields) { - // Add group stage to the pipeline - int stage = _query.length() + 1; - - // Add type, condition and fields - _query[stage]["type"] = "match"; - _query[stage]["condition"] = condition; - _query[stage]["fields"] = fields; - - // Return reference to pipeline to basically help in chaining - return Pipeline(_collection, _query, _duplex); -} - -Grandeur::Project::Datastore::Collection::Pipeline Grandeur::Project::Datastore::Collection::Pipeline::sort(Var specs) { - // Add sort stage to the pipeline - int stage = _query.length() + 1; - - // Add type and specs - _query[stage]["type"] = "match"; - _query[stage]["specs"] = specs; - - // Return reference to pipeline to basically help in chaining - return Pipeline(_collection, _query, _duplex); -} - -void Grandeur::Project::Datastore::Collection::Pipeline::execute(int nPage, Callback executed) { - // Define an object - Var oPayload; - // Formulate query - oPayload["collection"] = _collection; - oPayload["pipeline"] = _query; - oPayload["nPage"] = nPage; - - // Send to server - _duplex->send("/datastore/pipeline", oPayload, executed); -} diff --git a/src/DuplexHandler.cpp b/src/DuplexHandler.cpp index bd24ed0..ccc9fca 100755 --- a/src/DuplexHandler.cpp +++ b/src/DuplexHandler.cpp @@ -191,14 +191,6 @@ void DuplexHandler::receive(Var header, Var payload) // Response to Set has data in payload["update"]. else if (strcmp(task, "/device/data/set") == 0) data = payload["update"]; - // For datastore, we delete code and message from the payload and send the rest. - else if (strcmp(task, "/datastore/insert") == 0 || strcmp(task, "/datastore/delete") == 0 || - strcmp(task, "/datastore/update") == 0 || strcmp(task, "/datastore/pipeline") == 0) - { - data = payload; - data["code"] = undefined; - data["message"] = undefined; - } DEBUG_GRANDEUR("Response message:: code: %s, data: %s.", code, JSON.stringify(data).c_str()); diff --git a/src/Grandeur.cpp b/src/Grandeur.cpp index a248ad3..af4191a 100755 --- a/src/Grandeur.cpp +++ b/src/Grandeur.cpp @@ -46,11 +46,6 @@ Grandeur::Project::Device Grandeur::Project::device(String deviceId) { return Device(_duplex, deviceId); } -Grandeur::Project::Datastore Grandeur::Project::datastore(void) { - // Return the new datastore object. - return Datastore(_duplex); -} - void Grandeur::Project::loop(bool valve) { // Running duplex loop. _duplex->loop(valve); diff --git a/src/Grandeur.h b/src/Grandeur.h index e901e20..3f957ac 100755 --- a/src/Grandeur.h +++ b/src/Grandeur.h @@ -38,8 +38,6 @@ class Grandeur::Project { Project(DuplexHandler* duplex); // Class that models a Grandeur device. class Device; - // Class that models datastore. - class Datastore; // Connection related methods: // Schedules a connection handler function to be called on successful connection establishment @@ -52,7 +50,6 @@ class Grandeur::Project { // Instantiator methods — return reference to objects of their classes. Device device(String deviceId); - Datastore datastore(void); // This method runs the SDK. void loop(bool valve); @@ -129,72 +126,6 @@ class Grandeur::Project::Device { Data data(); }; -class Grandeur::Project::Datastore { - private: - // Stores reference to duplex channel we are connected through to Grandeur. - DuplexHandler* _duplex; - - public: - // Constructor - Datastore(); - Datastore(DuplexHandler* duplexHandler); - - // Class that models a datastore collection. - class Collection { - private: - // Stores reference to duplex channel we are connected through to Grandeur. - DuplexHandler* _duplex; - // Stores name of collection - String _name; - - public: - // Constructor - Collection(String name, DuplexHandler* duplexHandler); - - // Inserts documents. - void insert(Var documents, Callback inserted); - // Removes documents matching the filter. - void remove(Var filter, Callback removed); - // Updates documents matching the filter. - void update(Var filter, Var update, Callback updated); - // Performs a search a search on all documents. - void search(Var filter, Var projection, int nPage, Callback searched); - - - // Class that forms a pipeline of datastore collection operations to send them all at once - // to Grandeur. - class Pipeline { - private: - // Stores reference to duplex channel we are connected through to Grandeur. - DuplexHandler* _duplex; - // Stores the collection name - String _collection; - // Stores the whole operations pipeline. - Var _query; - - public: - // Constructor - Pipeline(String collection, Var query, DuplexHandler* duplexHandler); - - // Adds a match stage to pipeline. - Pipeline match(Var filter); - // Add project stage to pipeline. - Pipeline project(Var specs); - // Adds group stage to pipeline. - Pipeline group(Var condition, Var fields); - // Adds sort stage to pipeline. - Pipeline sort(Var specs); - // Execute the query by sending function - void execute(int nPage, Callback executed); - }; - - // Returns a new query pipeline. - Pipeline pipeline(void); - }; - // Gets reference to a particular collection of documents. - Collection collection(String name); -}; - extern Grandeur grandeur; #endif \ No newline at end of file From 5be580496d5916fa506eb617a245638cc9cfc20d Mon Sep 17 00:00:00 2001 From: MA Date: Mon, 26 Jun 2023 20:51:27 +0500 Subject: [PATCH 4/9] Device's "ACCESS-TOKEN" is renamed to "DEVICE-TOKEN" --- .../CrossListening-esp32/CrossListening-esp32.ino | 2 +- .../CrossListening-esp8266/CrossListening-esp8266.ino | 2 +- .../DashListening-App-esp32/DashListening-App-esp32.ino | 2 +- .../DashListening-App-esp8266/DashListening-App-esp8266.ino | 2 +- .../DashListening-Device-esp32/DashListening-Device-esp32.ino | 2 +- .../DashListening-Device-esp8266.ino | 2 +- .../HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino | 2 +- .../HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino index d6b2c93..348ff97 100644 --- a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino +++ b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino @@ -27,7 +27,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino b/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino index 45213c8..748476f 100644 --- a/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino +++ b/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino @@ -27,7 +27,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino b/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino index 397b45a..f884ee1 100644 --- a/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino +++ b/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino @@ -24,7 +24,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino b/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino index 7c35207..268e9fd 100644 --- a/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino +++ b/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino @@ -24,7 +24,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino b/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino index 3560d0b..49ba24c 100644 --- a/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino +++ b/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino @@ -24,7 +24,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino b/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino index f980bfe..7abc564 100644 --- a/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino +++ b/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino @@ -23,7 +23,7 @@ // Device's connection configurations: String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino b/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino index 8972d69..0bb90c6 100644 --- a/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino +++ b/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino @@ -18,7 +18,7 @@ // Device's connection configurations String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char* ssid = "YOUR-WIFI-SSID"; const char* passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino b/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino index c1a6a23..d4925cf 100644 --- a/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino +++ b/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino @@ -18,7 +18,7 @@ // Device's connection configurations String apiKey = "YOUR-PROJECT-APIKEY"; String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-ACCESS-TOKEN"; +String token = "YOUR-DEVICE-TOKEN"; const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; From 29294f95f3c6b8dd080539e52f26a6804e7aed2f Mon Sep 17 00:00:00 2001 From: MA Date: Mon, 26 Jun 2023 20:57:20 +0500 Subject: [PATCH 5/9] Added comments in examples explaining API key, device ID, and device token. --- .../CrossListening-esp32/CrossListening-esp32.ino | 6 +++--- .../CrossListening-esp8266/CrossListening-esp8266.ino | 6 +++--- .../DashListening-App-esp32/DashListening-App-esp32.ino | 6 +++--- .../DashListening-App-esp8266/DashListening-App-esp8266.ino | 6 +++--- .../DashListening-Device-esp32.ino | 6 +++--- .../DashListening-Device-esp8266.ino | 6 +++--- .../HelloGrandeur-esp32/HelloGrandeur-esp32.ino | 6 +++--- .../HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino index 348ff97..9c16150 100644 --- a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino +++ b/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino @@ -25,9 +25,9 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino b/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino index 748476f..3965c81 100644 --- a/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino +++ b/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino @@ -25,9 +25,9 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino b/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino index f884ee1..4f414da 100644 --- a/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino +++ b/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino @@ -22,9 +22,9 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino b/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino index 268e9fd..3f830dd 100644 --- a/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino +++ b/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino @@ -22,9 +22,9 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino b/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino index 49ba24c..4b94946 100644 --- a/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino +++ b/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino @@ -22,9 +22,9 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino b/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino index 7abc564..dae78b3 100644 --- a/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino +++ b/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino @@ -21,9 +21,9 @@ #include #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino b/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino index 0bb90c6..7d49b93 100644 --- a/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino +++ b/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino @@ -16,9 +16,9 @@ #include // Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char* ssid = "YOUR-WIFI-SSID"; const char* passphrase = "YOUR-WIFI-PASSWORD"; diff --git a/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino b/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino index d4925cf..2cd4eb4 100644 --- a/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino +++ b/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino @@ -16,9 +16,9 @@ #include // Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; -String deviceID = "YOUR-DEVICE-ID"; -String token = "YOUR-DEVICE-TOKEN"; +String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access +String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev +String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device const char *ssid = "YOUR-WIFI-SSID"; const char *passphrase = "YOUR-WIFI-PASSWORD"; From 7231cbcf55841360faedd08d125e0679f93279a4 Mon Sep 17 00:00:00 2001 From: MA Date: Mon, 26 Jun 2023 21:31:47 +0500 Subject: [PATCH 6/9] Examples structure is updated for better comprehension. --- .../CrossListening/CrossListening.ino} | 0 .../DashListening-App/DashListening-App.ino} | 0 .../DashListening-Device/DashListening-Device.ino} | 0 .../HelloGrandeur/HelloGrandeur.ino} | 0 .../CrossListening/CrossListening.ino} | 0 .../DashListening-App/DashListening-App.ino} | 0 .../DashListening-Device/DashListening-Device.ino} | 0 .../HelloGrandeur/HelloGrandeur.ino} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename examples/{CrossListening/CrossListening-esp32/CrossListening-esp32.ino => esp32/CrossListening/CrossListening.ino} (100%) rename examples/{DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino => esp32/DashListening-App/DashListening-App.ino} (100%) rename examples/{DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino => esp32/DashListening-Device/DashListening-Device.ino} (100%) rename examples/{HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino => esp32/HelloGrandeur/HelloGrandeur.ino} (100%) rename examples/{CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino => esp8266/CrossListening/CrossListening.ino} (100%) rename examples/{DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino => esp8266/DashListening-App/DashListening-App.ino} (100%) rename examples/{DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino => esp8266/DashListening-Device/DashListening-Device.ino} (100%) rename examples/{HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino => esp8266/HelloGrandeur/HelloGrandeur.ino} (100%) diff --git a/examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino b/examples/esp32/CrossListening/CrossListening.ino similarity index 100% rename from examples/CrossListening/CrossListening-esp32/CrossListening-esp32.ino rename to examples/esp32/CrossListening/CrossListening.ino diff --git a/examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino b/examples/esp32/DashListening-App/DashListening-App.ino similarity index 100% rename from examples/DashListening-App/DashListening-App-esp32/DashListening-App-esp32.ino rename to examples/esp32/DashListening-App/DashListening-App.ino diff --git a/examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino b/examples/esp32/DashListening-Device/DashListening-Device.ino similarity index 100% rename from examples/DashListening-Device/DashListening-Device-esp32/DashListening-Device-esp32.ino rename to examples/esp32/DashListening-Device/DashListening-Device.ino diff --git a/examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino b/examples/esp32/HelloGrandeur/HelloGrandeur.ino similarity index 100% rename from examples/HelloGrandeur/HelloGrandeur-esp32/HelloGrandeur-esp32.ino rename to examples/esp32/HelloGrandeur/HelloGrandeur.ino diff --git a/examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino b/examples/esp8266/CrossListening/CrossListening.ino similarity index 100% rename from examples/CrossListening/CrossListening-esp8266/CrossListening-esp8266.ino rename to examples/esp8266/CrossListening/CrossListening.ino diff --git a/examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino b/examples/esp8266/DashListening-App/DashListening-App.ino similarity index 100% rename from examples/DashListening-App/DashListening-App-esp8266/DashListening-App-esp8266.ino rename to examples/esp8266/DashListening-App/DashListening-App.ino diff --git a/examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino b/examples/esp8266/DashListening-Device/DashListening-Device.ino similarity index 100% rename from examples/DashListening-Device/DashListening-Device-esp8266/DashListening-Device-esp8266.ino rename to examples/esp8266/DashListening-Device/DashListening-Device.ino diff --git a/examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino similarity index 100% rename from examples/HelloGrandeur/HelloGrandeur-esp8266/HelloGrandeur-esp8266.ino rename to examples/esp8266/HelloGrandeur/HelloGrandeur.ino From 0accfe5638c8834caaeaa42ebe24f973ffb48041 Mon Sep 17 00:00:00 2001 From: MA Date: Tue, 27 Jun 2023 15:33:29 +0500 Subject: [PATCH 7/9] Broken links are updated. --- README.md | 2 +- examples/esp32/CrossListening/CrossListening.ino | 2 +- examples/esp32/DashListening-App/DashListening-App.ino | 2 +- examples/esp32/DashListening-Device/DashListening-Device.ino | 2 +- examples/esp32/HelloGrandeur/HelloGrandeur.ino | 2 +- examples/esp8266/CrossListening/CrossListening.ino | 2 +- examples/esp8266/DashListening-App/DashListening-App.ino | 2 +- examples/esp8266/DashListening-Device/DashListening-Device.ino | 2 +- examples/esp8266/HelloGrandeur/HelloGrandeur.ino | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6046b85..a741a89 100644 --- a/README.md +++ b/README.md @@ -912,7 +912,7 @@ void setup() { } void loop() { - myProject.loop(WiFiState == CONNECTED); // Same as "if(WiFiState == CONNECTED) myProject.loop();" + if(WiFiState == CONNECTED) myProject.loop(); } // **RESULT** // Runs the SDK only when the WiFi is connected. diff --git a/examples/esp32/CrossListening/CrossListening.ino b/examples/esp32/CrossListening/CrossListening.ino index 9c16150..5ac1572 100644 --- a/examples/esp32/CrossListening/CrossListening.ino +++ b/examples/esp32/CrossListening/CrossListening.ino @@ -17,7 +17,7 @@ * 2. Publish updates in variables to Grandeur every 5 seconds. * 3. Running the SDK only when a certain condition is true; in our case, if the WiFi is connected. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add a button and + * After uploading this sketch to your ESP, go to your device's canvas and add a button and * a display to control state and monitor voltage variable, respectively. */ diff --git a/examples/esp32/DashListening-App/DashListening-App.ino b/examples/esp32/DashListening-App/DashListening-App.ino index 4f414da..934307b 100644 --- a/examples/esp32/DashListening-App/DashListening-App.ino +++ b/examples/esp32/DashListening-App/DashListening-App.ino @@ -14,7 +14,7 @@ * It would be useful in building a DEVICE MONITOR which would show how your devices are * behaving in terms of their energy units consumed for example. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add + * After uploading this sketch to your ESP, go to your device's canvas and add * a display to monitor the voltage variable. */ diff --git a/examples/esp32/DashListening-Device/DashListening-Device.ino b/examples/esp32/DashListening-Device/DashListening-Device.ino index 4b94946..de08e3b 100644 --- a/examples/esp32/DashListening-Device/DashListening-Device.ino +++ b/examples/esp32/DashListening-Device/DashListening-Device.ino @@ -14,7 +14,7 @@ * It would be useful in building an INTERNET SWITCH to help you control your device without * caring about how your device responds to your commands. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add a button + * After uploading this sketch to your ESP, go to your device's canvas and add a button * to control the state variable. */ diff --git a/examples/esp32/HelloGrandeur/HelloGrandeur.ino b/examples/esp32/HelloGrandeur/HelloGrandeur.ino index 7d49b93..85b48ca 100644 --- a/examples/esp32/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp32/HelloGrandeur/HelloGrandeur.ino @@ -53,7 +53,7 @@ void loop() { // project.device(deviceID).data().get("state", getStateCallback); - Serial.println("Read the docs at https://github.com/grandeurtech/arduino-sdk."); + Serial.println("Read the docs at https://docs.grandeur.dev/references/device-sdk."); Serial.println("Also checkout other examples: \n- DashListening-Device \n- DashListening-App \n- CrossListening.\n"); } // This runs the SDK only when the WiFi is connected. diff --git a/examples/esp8266/CrossListening/CrossListening.ino b/examples/esp8266/CrossListening/CrossListening.ino index 3965c81..82969c5 100644 --- a/examples/esp8266/CrossListening/CrossListening.ino +++ b/examples/esp8266/CrossListening/CrossListening.ino @@ -17,7 +17,7 @@ * 2. Publish updates in variables to Grandeur every 5 seconds. * 3. Running the SDK only when a certain condition is true; in our case, if the WiFi is connected. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add a button and + * After uploading this sketch to your ESP, go to your device's canvas and add a button and * a display to control state and monitor voltage variable, respectively. */ diff --git a/examples/esp8266/DashListening-App/DashListening-App.ino b/examples/esp8266/DashListening-App/DashListening-App.ino index 3f830dd..0ce4b80 100644 --- a/examples/esp8266/DashListening-App/DashListening-App.ino +++ b/examples/esp8266/DashListening-App/DashListening-App.ino @@ -14,7 +14,7 @@ * It would be useful in building a DEVICE MONITOR which would show how your devices are * behaving in terms of their energy units consumed for example. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add + * After uploading this sketch to your ESP, go to your device's canvas and add * a display to monitor the voltage variable. */ diff --git a/examples/esp8266/DashListening-Device/DashListening-Device.ino b/examples/esp8266/DashListening-Device/DashListening-Device.ino index dae78b3..0eb2076 100644 --- a/examples/esp8266/DashListening-Device/DashListening-Device.ino +++ b/examples/esp8266/DashListening-Device/DashListening-Device.ino @@ -14,7 +14,7 @@ * It would be useful in building an INTERNET SWITCH to help you control your device without * caring about how your device responds to your commands. * - * After uploading this sketch to your ESP, go to https://canvas.grandeur.tech and add a button + * After uploading this sketch to your ESP, go to your device's canvas and add a button * to control the state variable. */ diff --git a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino index 2cd4eb4..e6f6e70 100644 --- a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino @@ -56,7 +56,7 @@ void loop() // project.device(deviceID).data().get("state", getStateCallback); - Serial.println("Read the docs at https://github.com/grandeurtech/arduino-sdk."); + Serial.println("Read the docs at https://docs.grandeur.dev/references/device-sdk."); Serial.println("Also checkout other examples: \n- DashListening-Device \n- DashListening-App \n- CrossListening.\n"); } // This runs the SDK only when the WiFi is connected. From 1aed1eb4b0a2429acb8a601ac188d1d2d0da3269 Mon Sep 17 00:00:00 2001 From: MA Date: Tue, 27 Jun 2023 19:53:10 +0500 Subject: [PATCH 8/9] Examples names are changed for better comprehension at a glance. --- .../ControlAndMonitorDevice.ino} | 6 ++---- .../ControlDevice.ino} | 3 +-- examples/esp32/HelloGrandeur/HelloGrandeur.ino | 2 +- .../MonitorDevice.ino} | 3 +-- .../ControlAndMonitorDevice.ino} | 4 +--- .../ControlDevice.ino} | 3 +-- examples/esp8266/HelloGrandeur/HelloGrandeur.ino | 2 +- .../MonitorDevice.ino} | 3 +-- 8 files changed, 9 insertions(+), 17 deletions(-) rename examples/esp32/{CrossListening/CrossListening.ino => ControlAndMonitorDevice/ControlAndMonitorDevice.ino} (94%) rename examples/esp32/{DashListening-Device/DashListening-Device.ino => ControlDevice/ControlDevice.ino} (95%) rename examples/esp32/{DashListening-App/DashListening-App.ino => MonitorDevice/MonitorDevice.ino} (95%) rename examples/esp8266/{CrossListening/CrossListening.ino => ControlAndMonitorDevice/ControlAndMonitorDevice.ino} (95%) rename examples/esp8266/{DashListening-Device/DashListening-Device.ino => ControlDevice/ControlDevice.ino} (95%) rename examples/esp8266/{DashListening-App/DashListening-App.ino => MonitorDevice/MonitorDevice.ino} (96%) diff --git a/examples/esp32/CrossListening/CrossListening.ino b/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino similarity index 94% rename from examples/esp32/CrossListening/CrossListening.ino rename to examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino index 5ac1572..dde6ce4 100644 --- a/examples/esp32/CrossListening/CrossListening.ino +++ b/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino @@ -1,5 +1,5 @@ /** - * @file CrossListening-esp32.ino + * @file ControlAndMonitorDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -8,9 +8,7 @@ * * Grandeur.h is used for device's communication with Grandeur. * WiFi.h is used for handling device's WiFi. - * - * Cross listening means when the device listens for updates from the app and the app - * listens for updates from the device. + * * This example illustrates pretty much every basic thing you'd need in order to monitor / * control your device through Grandeur. Here are some of those: * 1. Listen to Grandeur for updates in device variables. diff --git a/examples/esp32/DashListening-Device/DashListening-Device.ino b/examples/esp32/ControlDevice/ControlDevice.ino similarity index 95% rename from examples/esp32/DashListening-Device/DashListening-Device.ino rename to examples/esp32/ControlDevice/ControlDevice.ino index de08e3b..914ddd3 100644 --- a/examples/esp32/DashListening-Device/DashListening-Device.ino +++ b/examples/esp32/ControlDevice/ControlDevice.ino @@ -1,5 +1,5 @@ /** - * @file DashListening-Device-esp32.ino + * @file ControlDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -9,7 +9,6 @@ * Grandeur.h is used for device's communication with Grandeur. * WiFi.h is used for handling device's WiFi. * - * Dash listening is for one-way listening. * This example illustrates the use case of a device listening for updates from the app. * It would be useful in building an INTERNET SWITCH to help you control your device without * caring about how your device responds to your commands. diff --git a/examples/esp32/HelloGrandeur/HelloGrandeur.ino b/examples/esp32/HelloGrandeur/HelloGrandeur.ino index 85b48ca..1f9462d 100644 --- a/examples/esp32/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp32/HelloGrandeur/HelloGrandeur.ino @@ -1,5 +1,5 @@ /** - * @file HelloGrandeur-esp32.ino + * @file HelloGrandeur.ino * @date 21.02.2021 * @author Grandeur Technologies * diff --git a/examples/esp32/DashListening-App/DashListening-App.ino b/examples/esp32/MonitorDevice/MonitorDevice.ino similarity index 95% rename from examples/esp32/DashListening-App/DashListening-App.ino rename to examples/esp32/MonitorDevice/MonitorDevice.ino index 934307b..667fec5 100644 --- a/examples/esp32/DashListening-App/DashListening-App.ino +++ b/examples/esp32/MonitorDevice/MonitorDevice.ino @@ -1,5 +1,5 @@ /** - * @file DashListening-App-esp32.ino + * @file MonitorDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -9,7 +9,6 @@ * Grandeur.h is used for device's communication with Grandeur. * WiFi.h is used for handling device's WiFi. * - * Dash listening is for one-way listening. * This example illustrates the use case of an app listening for updates from the device. * It would be useful in building a DEVICE MONITOR which would show how your devices are * behaving in terms of their energy units consumed for example. diff --git a/examples/esp8266/CrossListening/CrossListening.ino b/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino similarity index 95% rename from examples/esp8266/CrossListening/CrossListening.ino rename to examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino index 82969c5..3a42f16 100644 --- a/examples/esp8266/CrossListening/CrossListening.ino +++ b/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino @@ -1,5 +1,5 @@ /** - * @file CrossListening-esp8266.ino + * @file ControlAndMonitorDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -9,8 +9,6 @@ * Grandeur.h is used for device's communication with Grandeur. * ESP8266WiFi.h is used for handling device's WiFi. * - * Cross listening means when the device listens for updates from the app and the app - * listens for updates from the device. * This example illustrates pretty much every basic thing you'd need in order to monitor / * control your device through Grandeur. Here are some of those: * 1. Listen to Grandeur for updates in device variables. diff --git a/examples/esp8266/DashListening-Device/DashListening-Device.ino b/examples/esp8266/ControlDevice/ControlDevice.ino similarity index 95% rename from examples/esp8266/DashListening-Device/DashListening-Device.ino rename to examples/esp8266/ControlDevice/ControlDevice.ino index 0eb2076..87bdb4d 100644 --- a/examples/esp8266/DashListening-Device/DashListening-Device.ino +++ b/examples/esp8266/ControlDevice/ControlDevice.ino @@ -1,5 +1,5 @@ /** - * @file DashListening-Device-esp8266.ino + * @file ControlDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -9,7 +9,6 @@ * Grandeur.h is used for device's communication with Grandeur. * ESP8266WiFi.h is used for handling device's WiFi. * - * Dash listening is for one-way listening. * This example illustrates the use case of a device listening for updates from the app. * It would be useful in building an INTERNET SWITCH to help you control your device without * caring about how your device responds to your commands. diff --git a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino index e6f6e70..42f9f1f 100644 --- a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino @@ -1,5 +1,5 @@ /** - * @file HelloGrandeur-esp8266.ino + * @file HelloGrandeur.ino * @date 21.02.2021 * @author Grandeur Technologies * diff --git a/examples/esp8266/DashListening-App/DashListening-App.ino b/examples/esp8266/MonitorDevice/MonitorDevice.ino similarity index 96% rename from examples/esp8266/DashListening-App/DashListening-App.ino rename to examples/esp8266/MonitorDevice/MonitorDevice.ino index 0ce4b80..2fcac4b 100644 --- a/examples/esp8266/DashListening-App/DashListening-App.ino +++ b/examples/esp8266/MonitorDevice/MonitorDevice.ino @@ -1,5 +1,5 @@ /** - * @file DashListening-App-esp8266.ino + * @file MonitorDevice.ino * @date 21.02.2021 * @author Grandeur Technologies * @@ -9,7 +9,6 @@ * Grandeur.h is used for device's communication to Grandeur. * ESP8266WiFi.h is used for handling device's WiFi. * - * Dash listening is for one-way listening. * This example illustrates the use case of an app listening for updates from the device. * It would be useful in building a DEVICE MONITOR which would show how your devices are * behaving in terms of their energy units consumed for example. From d51a584f73430cc968e24e5aba2a92fa647e4d86 Mon Sep 17 00:00:00 2001 From: MA Date: Tue, 27 Jun 2023 19:56:30 +0500 Subject: [PATCH 9/9] Examples variables are formatted from String to Undefined variables so the examples don't compile without user putting his/her credentials. --- .../ControlAndMonitorDevice.ino | 10 +++++----- examples/esp32/ControlDevice/ControlDevice.ino | 10 +++++----- examples/esp32/HelloGrandeur/HelloGrandeur.ino | 10 +++++----- examples/esp32/MonitorDevice/MonitorDevice.ino | 10 +++++----- .../ControlAndMonitorDevice.ino | 10 +++++----- examples/esp8266/ControlDevice/ControlDevice.ino | 10 +++++----- examples/esp8266/HelloGrandeur/HelloGrandeur.ino | 10 +++++----- examples/esp8266/MonitorDevice/MonitorDevice.ino | 10 +++++----- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino b/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino index dde6ce4..763d056 100644 --- a/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino +++ b/examples/esp32/ControlAndMonitorDevice/ControlAndMonitorDevice.ino @@ -23,11 +23,11 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis(); diff --git a/examples/esp32/ControlDevice/ControlDevice.ino b/examples/esp32/ControlDevice/ControlDevice.ino index 914ddd3..30f384d 100644 --- a/examples/esp32/ControlDevice/ControlDevice.ino +++ b/examples/esp32/ControlDevice/ControlDevice.ino @@ -21,11 +21,11 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis(); diff --git a/examples/esp32/HelloGrandeur/HelloGrandeur.ino b/examples/esp32/HelloGrandeur/HelloGrandeur.ino index 1f9462d..76f1da9 100644 --- a/examples/esp32/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp32/HelloGrandeur/HelloGrandeur.ino @@ -16,11 +16,11 @@ #include // Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char* ssid = "YOUR-WIFI-SSID"; -const char* passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char* ssid = YOUR_WIFI_SSID; +const char* passphrase = YOUR_WIFI_PASSWORD; // Object of Grandeur project. Grandeur::Project project; diff --git a/examples/esp32/MonitorDevice/MonitorDevice.ino b/examples/esp32/MonitorDevice/MonitorDevice.ino index 667fec5..917aa88 100644 --- a/examples/esp32/MonitorDevice/MonitorDevice.ino +++ b/examples/esp32/MonitorDevice/MonitorDevice.ino @@ -21,11 +21,11 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis(); diff --git a/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino b/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino index 3a42f16..a9c99ed 100644 --- a/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino +++ b/examples/esp8266/ControlAndMonitorDevice/ControlAndMonitorDevice.ino @@ -23,11 +23,11 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis(); diff --git a/examples/esp8266/ControlDevice/ControlDevice.ino b/examples/esp8266/ControlDevice/ControlDevice.ino index 87bdb4d..9cdf26b 100644 --- a/examples/esp8266/ControlDevice/ControlDevice.ino +++ b/examples/esp8266/ControlDevice/ControlDevice.ino @@ -20,11 +20,11 @@ #include #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis(); diff --git a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino index 42f9f1f..3b7b96d 100644 --- a/examples/esp8266/HelloGrandeur/HelloGrandeur.ino +++ b/examples/esp8266/HelloGrandeur/HelloGrandeur.ino @@ -16,11 +16,11 @@ #include // Device's connection configurations -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Object of Grandeur project. Grandeur::Project project; diff --git a/examples/esp8266/MonitorDevice/MonitorDevice.ino b/examples/esp8266/MonitorDevice/MonitorDevice.ino index 2fcac4b..45fc918 100644 --- a/examples/esp8266/MonitorDevice/MonitorDevice.ino +++ b/examples/esp8266/MonitorDevice/MonitorDevice.ino @@ -21,11 +21,11 @@ #include // Device's connection configurations: -String apiKey = "YOUR-PROJECT-APIKEY"; // Copy from https://console.grandeur.dev/access -String deviceID = "YOUR-DEVICE-ID"; // Copy your device ID from https://console.grandeur.dev -String token = "YOUR-DEVICE-TOKEN"; // Copy when you register a new device -const char *ssid = "YOUR-WIFI-SSID"; -const char *passphrase = "YOUR-WIFI-PASSWORD"; +String apiKey = YOUR_PROJECT_APIKEY; // Copy from https://console.grandeur.dev/access +String deviceID = YOUR_DEVICE_ID; // Copy your device ID from https://console.grandeur.dev +String token = YOUR_DEVICE_TOKEN; // Copy when you register a new device +const char *ssid = YOUR_WIFI_SSID; +const char *passphrase = YOUR_WIFI_PASSWORD; // Handles our 5 second timer in loop(). unsigned long currentTime = millis();