Skip to content

Changes to solve Fatal exception 28(LoadProhibitedCause) #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ThingerClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class ThingerClient : public thinger::thinger {
* Without a small delays between readings, the MKRGSM1400 seems to miss information, i.e, reading a byte
* after a byte. Maybe it is related to UART communication.
*/
delay(50);
#ifdef ARDUINO_SAMD_MKRGSM1400
delay(2);
#endif
Expand Down Expand Up @@ -567,4 +568,4 @@ inline bool inputResource<String>(pson& in, String& value){
inputValue_2(__VA_ARGS__),\
inputValue_1(__VA_ARGS__)\
)
#endif
#endif
11 changes: 10 additions & 1 deletion src/ThingerSmartConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class ThingerSmartConfig : public ThingerClient {
// try to connect to the last known Wifi Network
if(WiFi.SSID()!=NULL){
THINGER_DEBUG_VALUE("NETWORK", "Trying to connect to the last known network: ", WiFi.SSID());

// Modes that fix Fatal exception 28(LoadProhibitedCause) (https://github.com/thinger-io/Arduino-Library/issues/28)
WiFi.persistent(false);
WiFi.mode(WIFI_OFF);
WiFi.mode(WIFI_STA);

unsigned long wifi_timeout = millis();
WiFi.begin(WiFi.SSID().c_str(), WiFi.psk().c_str());
while(WiFi.status() != WL_CONNECTED && (millis() - wifi_timeout < WIFI_CONNECTION_TIMEOUT_MS)) {
Expand All @@ -77,6 +83,9 @@ class ThingerSmartConfig : public ThingerClient {
if(WiFi.status() != WL_CONNECTED){
unsigned long wifi_timeout = millis();
THINGER_DEBUG("NETWORK", "Waiting Smart Config...");
WiFi.persistent(false);
WiFi.mode(WIFI_OFF);
WiFi.mode(WIFI_STA);
WiFi.stopSmartConfig();
WiFi.beginSmartConfig();
while(!WiFi.smartConfigDone()) {
Expand Down Expand Up @@ -136,4 +145,4 @@ class ThingerSmartConfig : public ThingerClient {
#endif
};

#endif
#endif
8 changes: 4 additions & 4 deletions src/thinger/thinger.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace thinger{
* @param data data to write defined in a pson structure
* @return
*/
bool write_bucket(const char* bucket_id, pson& data, bool confirm_write=false){
bool write_bucket(const char* bucket_id, pson& data, bool confirm_write=true){
thinger_message message;
message.set_signal_flag(thinger_message::BUCKET_DATA);
message.set_identifier(bucket_id);
Expand All @@ -272,7 +272,7 @@ namespace thinger{
* @param resource_name resource defined in the code, i.e., thing["location"]
* @return
*/
bool write_bucket(const char* bucket_id, thinger_resource& resource, bool confirm_write=false){
bool write_bucket(const char* bucket_id, thinger_resource& resource, bool confirm_write=true){
thinger_message message;
message.set_signal_flag(thinger_message::BUCKET_DATA);
message.set_identifier(bucket_id);
Expand All @@ -286,7 +286,7 @@ namespace thinger{
* @param resource_name resource identifier defined in the code, i.e, "location"
* @return
*/
bool write_bucket(const char* bucket_id, const char* resource_name, bool confirm_write=false){
bool write_bucket(const char* bucket_id, const char* resource_name, bool confirm_write=true){
return write_bucket(bucket_id, resources_[resource_name], confirm_write);
}

Expand Down Expand Up @@ -589,4 +589,4 @@ namespace thinger{
};
}

#endif
#endif