Skip to content

Commit

Permalink
documented changes in library!
Browse files Browse the repository at this point in the history
  • Loading branch information
thetechguy2016 committed Jul 23, 2020
1 parent 9b17440 commit 42122ab
Showing 1 changed file with 89 additions and 16 deletions.
105 changes: 89 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,33 @@ just a click away.**
## Documentation
AglowOta provide a very simple way to add OTA functionality to your device.

### Auto Update

```
ota.setAutoUpdate(true);
ota.begin(product_id, project_id, mod, tim, currentVersion );
```

## Sample Code
### Manual Update
```
ota.setCheckCallback(isAnyNewUpdate);
ota.begin(product_id, project_id, mod, tim, currentVersion);
void isAnyNewUpdate(uint16_t ver){
Serial.println(ver);
if(currentVersion > ver) {
// update trigger in manual update
ota.update();
}
}
```

## Auto Update Sample Code

```
#include <ESP8266WiFi.h>
#include <ESP8266httpUpdate.h>
#include "ota_https.h"
#include <WiFiClientSecure.h>
#define WIFI_SSID "Aglow"
Expand All @@ -79,36 +95,93 @@ DEV_MODE mod = TEST; // and "PROD" for production device
CHECK_TIME tim = MIN30; // and "MIN60" to check every 60 MIN
uint16_t currentVersion = 456;
// you will find product_id and project_id on https://ota.aglow.co.in
String project_id = "-Mkjahsdjuyowqod";
String product_id = "-Hyoaskjdksnlkdn";
void isAnyNewUpdate(uint16_t ver);
String project_id = "-MABYaaxuPPlubL9ThXH";
String product_id = "-MABZxCVaNXrxn0cTPdS";
OtaHttps ota;
void setup()
{
Serial.begin(115200);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
while (!Serial){}
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
ota.setAutoUpdate(true);
/*
This library will check the server every 30 Min or 60 Min based on what to select,
whenevery it will find version > then current version it will push new update.
*/
ota.begin(product_id, project_id, mod, tim, currentVersion );
ota.begin(product_id, project_id, mod, tim, currentVersion);
}
void loop(){}
void loop() {}
```

## Manual Update Sample Code

```
#include "ota_https.h"
#define WIFI_SSID "Aglow"
#define WIFI_PASSWORD "aglowbytickle"
/*
In test mode the api will check every 2 minute for testing purpose
as we have two different track please use TEST for testing purpose only as we
have to pay so much for the cloud call. and we give this service for free.
If you like our service please donate so that we can keep working for every one.
https://www.buymeacoffee.com/aglow
*/
DEV_MODE mod = TEST; // and "PROD" for production device
CHECK_TIME tim = MIN30; // and "MIN60" to check every 60 MIN
uint16_t currentVersion = 456;
void isAnyNewUpdate(uint16_t ver);
String project_id = "-MABYaaxuPPlubL9ThXH";
String product_id = "-MABZxCVaNXrxn0cTPdS";
OtaHttps ota;
void setup()
{
Serial.begin(115200);
while (!Serial){}
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
//setting up callback for https check for new version
ota.setCheckCallback(isAnyNewUpdate);
ota.begin(product_id, project_id, mod, tim, currentVersion);
}
// this function returns the Live version avalable on the dashbard.
// here you can check the current version on device and the version available on dashboard
// if the version is greater then the current version udpdate the device.
void isAnyNewUpdate(uint16_t ver){
Serial.println(ver);
if(currentVersion > ver) {
// update trigger in manual update
ota.update();
}
}
void loop() {}
```

0 comments on commit 42122ab

Please sign in to comment.