Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
### Major Releases v1.1.0

1. Fix Config Portal Bug. 
2. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](khoih-prog/Blynk_WM#25)
3. Use more efficient [FlashStorage_STM32 Library](https://github.com/khoih-prog/FlashStorage_STM32) to save data to emulaled-EEPROM.
4. Add support to new [**`EthernetENC library`**](https://github.com/jandrassy/EthernetENC) for ENC28J60.
  • Loading branch information
khoih-prog authored Jan 31, 2021
1 parent bfdd5a3 commit 8f7f683
Show file tree
Hide file tree
Showing 74 changed files with 9,906 additions and 3,178 deletions.
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
## Contributing to BlynkEthernet_WM
## Contributing to BlynkEthernet_STM32_WM

### Reporting Bugs

Please report bugs in BlynkEthernet_WM if you find them.
Please report bugs in BlynkEthernet_STM32_WM if you find them.

However, before reporting a bug please check through the following:

* [Existing Open Issues](https://github.com/khoih-prog/BlynkEthernet_WM/issues) - someone might have already encountered this.
* [Existing Open Issues](https://github.com/khoih-prog/BlynkEthernet_STM32_WM/issues) - someone might have already encountered this.

If you don't find anything, please [open a new issue](https://github.com/khoih-prog/BlynkEthernet_WM/issues/new).
If you don't find anything, please [open a new issue](https://github.com/khoih-prog/BlynkEthernet_STM32_WM/issues/new).

### How to submit a bug report

Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.11) or Platform.io version
* Arduino Core Version (e.g. Arduino v1.8.2)
* Arduino Board (UNO, Mega2560, Nano, etc)
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
* Arduino Core for STM32 Version (e.g. Arduino Core for STM32 Version v1.9.0)
* Arduino STM32 Board (STM32F7 Nucleo-144 F767ZI, etc)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
Expand All @@ -27,10 +27,10 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.11
Arduino Core Version 1.8.2
OS: Ubuntu 16.04 LTS
Linux Inspiron 4.4.0-170-generic #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Arduino IDE version: 1.8.13
Arduino Core for STM32 Version 1.9.0
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-64-generic #72-Ubuntu SMP Fri Jan 15 10:27:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Context:
The board couldn't autoreconnect to Local Blynk Server after router power recycling.
Expand All @@ -45,7 +45,7 @@ Steps to reproduce:

Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.

There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/BlynkEthernet_WM/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/BlynkEthernet_STM32_WM/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.

### Sending Pull Requests

Expand Down
2,222 changes: 1,925 additions & 297 deletions README.md

Large diffs are not rendered by default.

281 changes: 98 additions & 183 deletions examples/AM2315_W5100/AM2315_W5100.ino
Original file line number Diff line number Diff line change
@@ -1,183 +1,27 @@
/****************************************************************************************************************************
AM2315_W5100.ino
For STM32 running built-in Ethernet
BlynkSimpleEthernet_WM is a library for the AVR / Teensy platform to enable easy
configuration/reconfiguration and autoconnect/autoreconnect of Ethernet Shield W5x00/Blynk
Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_ESPManager
Licensed under MIT license
Version: 1.0.4
Original Blynk Library author:
@file BlynkGsmClient.h
@author Volodymyr Shymanskyy
@license This project is released under the MIT License (MIT)
@copyright Copyright (c) 2015 Volodymyr Shymanskyy
@date Jan 2015
@brief
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/02/2020 Initial coding for STM32 running built-in Ethernet, ENC28J60 or W5x00 Ethernet shields
1.0.1 K Hoang 03/03/2020 Fix bug for built-in Ethernet LAN8742A
1.0.2 K Hoang 06/03/2020 Fix crashing bug when using dynamic EthernetServer
1.0.3 K Hoang 10/03/2020 Reduce html and code size
1.0.4 K Hoang 20/04/2020 Add MultiBlynk, dynamic parameters, special chars input
AM2315_W5100.ino
For STM32 running W5x00 Ethernet shields
BlynkSTM32Ethernet_WM is a library for the STM32 running built-in Ethernet, ENC28J60 or W5x00 Ethernet shields
to enable easy configuration/reconfiguration and autoconnect/autoreconnect to Blynk
Forked from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases
Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_ESPManager
Licensed under MIT license
Version: 1.1.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 28/02/2020 Initial coding for STM32 running built-in Ethernet, ENC28J60 or W5x00 Ethernet shields
1.0.1 K Hoang 03/03/2020 Fix bug for built-in Ethernet LAN8742A
1.0.2 K Hoang 06/03/2020 Fix crashing bug when using dynamic EthernetServer
1.0.3 K Hoang 10/03/2020 Reduce html and code size
1.0.4 K Hoang 20/04/2020 Add MultiBlynk, dynamic parameters, special chars input
1.1.0 K Hoang 30/01/2021 Fix ConfigPortal bug. Add software Config Portal request. Use FlashStorage_STM32.
*****************************************************************************************************************************/

#if defined(ESP8266) || defined(ESP32) || defined(AVR) || (ARDUINO_SAM_DUE) || defined(CORE_TEENSY)
#error This code is designed to run on STM32 platform, not AVR, Teensy, SAM DUE, SAMD, ESP8266 nor ESP32! Please check your Tools->Board setting.
#endif

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define USE_BUILTIN_ETHERNET false
// If don't use USE_BUILTIN_ETHERNET, and USE_UIP_ETHERNET => use W5x00 with Ethernet library
#define USE_UIP_ETHERNET false

#if (USE_BUILTIN_ETHERNET)
#define ETHERNET_NAME "Built-in LAN8742A Ethernet"
#elif (USE_UIP_ETHERNET)
#define ETHERNET_NAME "ENC28J60 Ethernet Shield"
#else
#define ETHERNET_NAME "W5x00 Ethernet Shield"
#endif

#if defined(STM32F0)
#warning STM32F0 board selected
#define DEVICE_NAME "STM32F0"
#elif defined(STM32F1)
#warning STM32F1 board selected
#define DEVICE_NAME "STM32F1"
#elif defined(STM32F2)
#warning STM32F2 board selected
#define DEVICE_NAME "STM32F2"
#elif defined(STM32F3)
#warning STM32F3 board selected
#define DEVICE_NAME "STM32F3"
#elif defined(STM32F4)
#warning STM32F4 board selected
#define DEVICE_NAME "STM32F4"
#elif defined(STM32F7)
#warning STM32F7 board selected
#define DEVICE_NAME "STM32F7"
#else
#warning STM32 unknown board selected
#define DEVICE_NAME "STM32 Unknown"
#endif

#define BLYNK_NO_YIELD

#define USE_BLYNK_WM true
//#define USE_BLYNK_WM false

#define USE_DYNAMIC_PARAMETERS true

// Start location in EEPROM to store config data. Default 0.
// Config data Size currently is 128 bytes w/o chksum, 132 with chksum)
#define EEPROM_START 0

#define USE_SSL false

#if USE_BLYNK_WM

#if USE_SSL
// Need ArduinoECCX08 and ArduinoBearSSL libraries
// Currently, error not enough memory for many STM32 boards. Don't use
#error SSL not support
#else
#if USE_BUILTIN_ETHERNET
#include <BlynkSTM32BIEthernet_WM.h>
#elif USE_UIP_ETHERNET
#include <BlynkSTM32UIPEthernet_WM.h>
#else
#include <BlynkSTM32Ethernet_WM.h>
#endif
#endif

/////////////// Start dynamic Credentials ///////////////

//Defined in <BlynkEthernet_WM.h>
/**************************************
#define MAX_ID_LEN 5
#define MAX_DISPLAY_NAME_LEN 16
typedef struct
{
char id [MAX_ID_LEN + 1];
char displayName [MAX_DISPLAY_NAME_LEN + 1];
char *pdata;
uint8_t maxlen;
} MenuItem;
**************************************/

#if USE_DYNAMIC_PARAMETERS

#define MAX_MQTT_SERVER_LEN 34
char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "";

#define MAX_MQTT_PORT_LEN 6
char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "";

#define MAX_MQTT_USERNAME_LEN 34
char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "";

#define MAX_MQTT_PW_LEN 34
char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "";

#define MAX_MQTT_SUBS_TOPIC_LEN 34
char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "";

#define MAX_MQTT_PUB_TOPIC_LEN 34
char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "";

MenuItem myMenuItems [] =
{
{ "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN },
{ "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN },
{ "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN },
{ "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN },
{ "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN },
{ "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN },
};

uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize;

#else

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;
#endif


/////// // End dynamic Credentials ///////////

#else //USE_BLYNK_WM

#if USE_BUILTIN_ETHERNET
#include <BlynkSimple_STM32BI_Ethernet.h>
#elif USE_UIP_ETHERNET
#include <BlynkSimpleUIPEthernet.h>
#else
#include <BlynkSimpleEthernet.h>
#endif

#define USE_LOCAL_SERVER true

#if USE_LOCAL_SERVER
char auth[] = "******";
char server[] = "account.duckdns.org";
//char server[] = "192.168.2.112";
#else
char auth[] = "******";
char server[] = "blynk-cloud.com";
#endif

#define BLYNK_HARDWARE_PORT 8080
#endif //USE_BLYNK_WM
#include "defines.h"
#include "Credentials.h"
#include "dynamicParams.h"

#define W5100_CS 10
#define SDCARD_CS 4
Expand Down Expand Up @@ -223,10 +67,78 @@ void ReadData()
Blynk.virtualWrite(V2, humidity);
}

#define BLYNK_PIN_FORCED_CONFIG V10
#define BLYNK_PIN_FORCED_PERS_CONFIG V20

// Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal
BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG)
{
if (param.asInt())
{
Serial.println( F("\nCP Button Hit. Rebooting") );

// This will keep CP once, clear after reset, even you didn't enter CP at all.
Blynk.resetAndEnterConfigPortal();
}
}

// Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal
BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG)
{
if (param.asInt())
{
Serial.println( F("\nPersistent CP Button Hit. Rebooting") );

// This will keep CP forever, until you successfully enter CP, and Save data to clear the flag.
Blynk.resetAndEnterConfigPortalPersistent();
}
}

void heartBeatPrint()
{
static int num = 1;

if (Blynk.connected())
Serial.print(F("B"));
else
Serial.print(F("F"));

if (num == 80)
{
Serial.println();
num = 1;
}
else if (num++ % 10 == 0)
{
Serial.print(F(" "));
}
}

void check_status()
{
static unsigned long checkstatus_timeout = 0;

#define STATUS_CHECK_INTERVAL 60000L

// Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
{
heartBeatPrint();
checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
}
}

void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("\nStart AM2315_W5100 on STM32 running " + String(ETHERNET_NAME) + " " + String(DEVICE_NAME));
while (!Serial);

delay(200);

Serial.print(F("\nStart AM2315_W5100 on ")); Serial.print(BOARD_NAME);
Serial.print(F(" using ")); Serial.println(SHIELD_TYPE);
Serial.println(BLYNK_ETHERNET_STM32_WM_VERSION);

#if !(USE_BUILTIN_ETHERNET || USE_UIP_ETHERNET)
pinMode(SDCARD_CS, OUTPUT);
Expand Down Expand Up @@ -268,13 +180,15 @@ void setup()
}

#if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS)
void displayCredentials(void)
void displayCredentials()
{
Serial.println("\nYour stored Credentials :");
Serial.println(F("\nYour stored Credentials :"));

for (int i = 0; i < NUM_MENU_ITEMS; i++)
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
Serial.println(String(myMenuItems[i].displayName) + " = " + myMenuItems[i].pdata);
Serial.print(myMenuItems[i].displayName);
Serial.print(F(" = "));
Serial.println(myMenuItems[i].pdata);
}
}
#endif
Expand All @@ -283,13 +197,14 @@ void loop()
{
Blynk.run();
timer.run();
check_status();

#if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS)
static bool displayedCredentials = false;

if (!displayedCredentials)
{
for (int i = 0; i < NUM_MENU_ITEMS; i++)
for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++)
{
if (!strlen(myMenuItems[i].pdata))
{
Expand Down
Loading

0 comments on commit 8f7f683

Please sign in to comment.