Skip to content
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

ESP32 Arduino Rainmaker Error #6435

Closed
1 task done
gcohen10 opened this issue Mar 16, 2022 · 19 comments
Closed
1 task done

ESP32 Arduino Rainmaker Error #6435

gcohen10 opened this issue Mar 16, 2022 · 19 comments
Assignees
Labels
Resolution: Unable to reproduce With given information issue is unable to reproduce Type: Question Only question
Milestone

Comments

@gcohen10
Copy link

Board

ESP32-DevKitC-V4

Device Description

DevKitC

Hardware Configuration

N/A

Version

latest master

IDE Name

Arduino

Operating System

Windows 10

Flash frequency

40Mhz

PSRAM enabled

no

Upload speed

115200

Description

when I try to connect it to the Wi-Fi network using the Rainmaker app it gives me the following error message "Error, No Bluetooth device found with the given prefix"

I tried with both BLE and SoftAP methods and both don't work and when I go on the Wi-Fi and BLE scanner I dont even see it on the list of devices.

Sketch

//This example demonstrates the ESP RainMaker with a standard Switch device.
#include "RMaker.h"
#include "WiFi.h"
#include "WiFiProv.h"

#define DEFAULT_POWER_MODE true
const char *service_name = "PROV_1234";
const char *pop = "abcd1234";

//GPIO for push button
static int gpio_0 = 0;
//GPIO for virtual device
static int gpio_switch = 16;
/* Variable for reading pin status*/
bool switch_state = true;

//The framework provides some standard device types like switch, lightbulb, fan, temperaturesensor.
static Switch my_switch("Switch", &gpio_switch);

void sysProvEvent(arduino_event_t *sys_event)
{
    switch (sys_event->event_id) {      
        case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32
        Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
        printQR(service_name, pop, "ble");
#else
        Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
        printQR(service_name, pop, "softap");
#endif        
        break;
    }
}

void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
    const char *device_name = device->getDeviceName();
    const char *param_name = param->getParamName();

    if(strcmp(param_name, "Power") == 0) {
        Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
        switch_state = val.val.b;
        (switch_state == false) ? digitalWrite(gpio_switch, LOW) : digitalWrite(gpio_switch, HIGH);
        param->updateAndReport(val);
    }
}

void setup()
{
    Serial.begin(115200);
    pinMode(gpio_0, INPUT);
    pinMode(gpio_switch, OUTPUT);
    digitalWrite(gpio_switch, DEFAULT_POWER_MODE);

    Node my_node;    
    my_node = RMaker.initNode("ESP RainMaker Node");

    //Standard switch device
    my_switch.addCb(write_callback);
    
    //Add switch device to the node   
    my_node.addDevice(my_switch);

    //This is optional 
    RMaker.enableOTA(OTA_USING_PARAMS);
    //If you want to enable scheduling, set time zone for your region using setTimeZone(). 
    //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
    // RMaker.setTimeZone("Asia/Shanghai");
    // Alternatively, enable the Timezone service and let the phone apps set the appropriate timezone
    RMaker.enableTZService();

    RMaker.enableSchedule();

    RMaker.start();

    WiFi.onEvent(sysProvEvent);
#if CONFIG_IDF_TARGET_ESP32
    WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#else
    WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#endif
}

void loop()
{
    if(digitalRead(gpio_0) == LOW) { //Push button pressed

        // Key debounce handling
        delay(100);
        int startTime = millis();
        while(digitalRead(gpio_0) == LOW) delay(50);
        int endTime = millis();

        if ((endTime - startTime) > 10000) {
          // If key pressed for more than 10secs, reset all
          Serial.printf("Reset to factory.\n");
          RMakerFactoryReset(2);
        } else if ((endTime - startTime) > 3000) {
          Serial.printf("Reset Wi-Fi.\n");
          // If key pressed for more than 3secs, but less than 10, reset Wi-Fi
          RMakerWiFiReset(2);
        } else {
          // Toggle device state
          switch_state = !switch_state;
          Serial.printf("Toggle State to %s.\n", switch_state ? "true" : "false");
          my_switch.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, switch_state);
          (switch_state == false) ? digitalWrite(gpio_switch, LOW) : digitalWrite(gpio_switch, HIGH);
      }
    }
    delay(100);
}

Debug Message

None.

Other Steps to Reproduce

I tried with 2 different ESP32's but I am getting the same result. I am not able to detect the ESP32 via BLE or SoftAP mode.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@gcohen10 gcohen10 added the Status: Awaiting triage Issue is waiting for triage label Mar 16, 2022
@me-no-dev
Copy link
Member

Since you are using Git, could I bother you to switch to the esp32-s3-support branch and give it another go? We have updated RainMaker in that branch

@gcohen10
Copy link
Author

gcohen10 commented Mar 16, 2022

I am not using ESP32-S3 and also not using git. I am using Arduino IDE with a normal ESP32 WROOM module. What does git have to do with it ?
When I flash the Arduino example I don’t see any errors. I just see the QR code and URL link when I scan it I get an error message telling me the following:
“No Bluetooth device found with the given prefix“ I get the same message for BLE and SoftAP method and I can’t see the device in the BLE and Wi-Fi scanner.

@me-no-dev
Copy link
Member

that branch support all other chips + ESP32-S3 and has updated code in many places. I asked you so because that is what you posted above:

Version

latest master

@gcohen10
Copy link
Author

Sorry I meant to write master branch.

@gcohen10
Copy link
Author

gcohen10 commented Mar 16, 2022

Rainmaker partition scheme is only available for ESP32 Dev Module on Arduino. I cannot see that option on any other module on the boards manager. does the partition scheme matter ?

@me-no-dev
Copy link
Member

you should not need a special partition and since you are using ESP32-WROOM, you can safely select the "ESP32 Dev Module". It covers ALL ESP32 modules and variants (not S2, S3 C3, etc.). And is you are using "master branch" then you still say that you are using the git version of this repo and you could just go in there and git checkout esp32-s3-support to switch to the branch I asked :)

@gcohen10
Copy link
Author

OK. But why can’t I see the device PROV_1234 in the Wi-Fi and BLE scanner ?

@me-no-dev
Copy link
Member

did you try the new branch? RainMaker in master is very old (more than a year)

@gcohen10
Copy link
Author

I only tried the master branch

@me-no-dev
Copy link
Member

And are you willing to try the other branch? Your other option is to wait until we merge it into master and then you update your local copy.

@gcohen10
Copy link
Author

I will try the other branch

@VojtechBartoska VojtechBartoska added Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels Mar 16, 2022
@VojtechBartoska VojtechBartoska added this to the 2.0.3 milestone Mar 29, 2022
@VojtechBartoska VojtechBartoska added the Status: Test needed Issue needs testing label Mar 29, 2022
@VojtechBartoska
Copy link
Contributor

Hello @gcohen10, can you please give it a try on 2.0.3-Rc1? Thanks for your help!

@VojtechBartoska
Copy link
Contributor

Hello, any updates? Thanks!

@VojtechBartoska
Copy link
Contributor

@gcohen10 Any chance you have tested this?

@ncohen17
Copy link

Hi @VojtechBartoska ,

I tested it and still has the same issue.

@pedrominatel
Copy link
Member

Hello @gcohen10 and @ncohen17,

I'm testing on ESP32-DevKitC and I'm getting this error:

If QR code is not visible, copy paste the below URL in a browser.
https://rainmaker.espressif.com/qrcode.html?data={"ver":"v1","name":"PROV_1234","pop":"abcd1234","transport":"ble"}
E (39642) wifi_prov_mgr: Failed to create prov_stop_task!

abort() was called at PC 0x4015feff on core 0

Backtrace:0x40083341:0x3ffdd8300x40094ce5:0x3ffdd850 0x4009a3c1:0x3ffdd870 0x4015feff:0x3ffdd8f0 0x401613d1:0x3ffdd920 0x40161470:0x3ffdd940 0x4016161b:0x3ffdd960 0x40161eb1:0x3ffdd9e0 0x4016206f:0x3ffdda50 0x401693db:0x3ffdda90 0x4016ab61:0x3ffddae0 0x4016b329:0x3ffddb20 0x4013134e:0x3ffddb60 0x40131cf6:0x3ffddb80 0x40125735:0x3ffddbd0 0x401275f3:0x3ffddbf0 

ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0

Is this error similar to the error you are reporting?

me-no-dev pushed a commit that referenced this issue Apr 26, 2022
* Added RainMaker support on Arduino IDE for ESP32-C3/S2/S3

Closes #6573
Note related to the issue #6435
Jason2866 added a commit to tasmota/arduino-esp32 that referenced this issue Apr 26, 2022
* LittleFs is working with C3

* Delete .skip.esp32c3

* Add support for extra flash images (espressif#6625)

This PR adds support for uploading additional flash images (e.g. Adafruit Tiny UF2 bootloader) specified in board manifests.

Additionally, the PR switches the PlatformIO CI script to the upstream version of the ESP32 dev-platform (basically reverts changes introduced in espressif#5387 as they are no longer required).

* publish.yml: Remove a leftover parenthesis that was making the workflow (espressif#6620)

Description of Change

Remove a leftover parenthesis that was making the workflow that was making the workflow invalid.

Tests scenarios

Github Workflow.

Related links

https://github.com/espressif/arduino-esp32/actions/runs/2213167501

Signed-off-by: Abdelatif Guettouche <[email protected]>

* Enable LittleFs sketches for C3 (espressif#6618)

* LittleFs is working with C3

* Delete .skip.esp32c3

* Update LittleFS PlatformIO example (espressif#6617)

* Added RainMaker support on Arduino IDE for ESP32-C3/S2/S3 (espressif#6598)

* Added RainMaker support on Arduino IDE for ESP32-C3/S2/S3

Closes espressif#6573
Note related to the issue espressif#6435

* Touch change to init only selected GPIO. (espressif#6609)

* Separated init for touch / channel called by touchRead()

* compile error

* Fixed touch_V2 + ISR

* Allow BluetoothSerial::connect() with specified channel and more options (espressif#6380)

* BTAddress const, add bool()

* BTAdvertisedDevice: const functions

* BluetoothSerial: add: getChannels, add isClosed, add read/peek timeout, add connect with channel#

* BluetoothSerial: add sec_mask, role in ::connect

* BluetoothSerial add discover and connect with channel number example

* DiscoverConnect: add SPP_ENABLED check

* DiscoverConnect: disable on esp32s3

* Fixes stream load memory leak in WifiSecureClient for SSL CACert, Certificate, and (espressif#6387)

Private Key. Issue presented during any subsequent invocation of loadCACert, loadCertificate, and
loadPrivateKey, respectively, after the first invocation.

* Call i2c_set_timeout in i2cSetClock (espressif#6537)

* Uniform behaviour of WiFiClientSecure and WiFiClient setTimeout() (espressif#6562)

* Uniform timeout WiFiClient-WiFiClientSecure

* Added missing prototype

* Add socket check on setTimeout

* enh(log) salvage TAG from ESP_IDF log-statements > (espressif#6567)

by converting result log-rows from the 1st line to the 2nd (`NET` is the tag):
```
[ 73419][D][telelogger.cpp:915] telemetry(): state: 33C

[ 73419][D][telelogger.cpp:915] telemetry(): [NET] state: 33C
```

Co-authored-by: Me No Dev <[email protected]>

* add AirM2M_CORE_ESP32C3 board (espressif#6613)

* add AirM2M_CORE_ESP32C3 board

* Added Unexpected Maker Reflow Master Pro (UM RMP) board (espressif#6630)

Fixed wrong SCK and MISO pins for TinyS2

* Tasmota changes (#24)

* Update install-arduino-core-esp32.sh

* Update CMakeLists.txt

* Update Esp.cpp

* Update Updater.cpp

Co-authored-by: Valerii Koval <[email protected]>
Co-authored-by: Abdelatif Guettouche <[email protected]>
Co-authored-by: Pedro Minatel <[email protected]>
Co-authored-by: Jan Procházka <[email protected]>
Co-authored-by: Christian Ferbar <[email protected]>
Co-authored-by: Billy <[email protected]>
Co-authored-by: Paul <[email protected]>
Co-authored-by: Gonzalo Brusco <[email protected]>
Co-authored-by: Kostis Anagnostopoulos <[email protected]>
Co-authored-by: Me No Dev <[email protected]>
Co-authored-by: Darren Cheng <[email protected]>
Co-authored-by: Unexpected Maker <[email protected]>
@VojtechBartoska VojtechBartoska modified the milestones: 2.0.3, 2.1.0 Apr 28, 2022
@pedrominatel
Copy link
Member

Should we close this issue? I can't reproduce it and no more feedback about this issue on 2.0.3.

@VojtechBartoska @ncohen17 @gcohen10

@VojtechBartoska
Copy link
Contributor

Closing the issue, if needed you can reopen it.

Repository owner moved this from In Progress to Done in Arduino ESP32 Core Project Roadmap May 26, 2022
@VojtechBartoska VojtechBartoska added Resolution: Unable to reproduce With given information issue is unable to reproduce and removed Status: Test needed Issue needs testing Resolution: Awaiting response Waiting for response of author labels May 26, 2022
@zakirox123
Copy link

zakirox123 commented Oct 10, 2022

i am using ESP-WROOM-32 Device with Rainmaker App and having a problem tried with BLE and SoftAp, no luck BLE Error message "Communication Failed" sometime it says "Cannot find the device"
SoftAP Error message "Assisted Claiming not supported for SoftAP. Cannot Proceed" again tried to flashed with new firmware using espressif firmware tool still no luck. Tried to connect with nRF Connect App, got an error in log "Error (0x85): GATT ERROR" if i use auto connect it will get connect after long time to nRF Connect App
Did you find any solution if so Please help me?

` #include "RMaker.h"
#include "WiFi.h"
#include "WiFiProv.h"

const char *service_name = "PROV_12345";
const char *pop = "123456";

// define the Device Names
char deviceName_1[] = "Switch1";
char deviceName_2[] = "Switch2";
char deviceName_3[] = "Switch3";
char deviceName_4[] = "Switch4";

// define the GPIO connected with Relays and switches
static uint8_t RelayPin1 = 23; //D23
static uint8_t RelayPin2 = 22; //D22
static uint8_t RelayPin3 = 21; //D21
static uint8_t RelayPin4 = 19; //D19

static uint8_t SwitchPin1 = 13; //D13
static uint8_t SwitchPin2 = 12; //D12
static uint8_t SwitchPin3 = 14; //D14
static uint8_t SwitchPin4 = 27; //D27

static uint8_t wifiLed = 2; //D2
static uint8_t gpio_reset = 0;

/* Variable for reading pin status*/
// Relay State
bool toggleState_1 = LOW; //Define integer to remember the toggle state for relay 1
bool toggleState_2 = LOW; //Define integer to remember the toggle state for relay 2
bool toggleState_3 = LOW; //Define integer to remember the toggle state for relay 3
bool toggleState_4 = LOW; //Define integer to remember the toggle state for relay 4

// Switch State
bool SwitchState_1 = LOW;
bool SwitchState_2 = LOW;
bool SwitchState_3 = LOW;
bool SwitchState_4 = LOW;

//The framework provides some standard device types like switch, lightbulb, fan, temperature sensor.
static Switch my_switch1(deviceName_1, &RelayPin1);
static Switch my_switch2(deviceName_2, &RelayPin2);
static Switch my_switch3(deviceName_3, &RelayPin3);
static Switch my_switch4(deviceName_4, &RelayPin4);

void sysProvEvent(arduino_event_t *sys_event)
{

switch (sys_event->event_id) {      
    case ARDUINO_EVENT_PROV_START:

#if CONFIG_IDF_TARGET_ESP32

Serial.printf("\nProvisioning Started with name "%s" and PoP "%s" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");

    // digitalWrite(wifiLed, true);

#else
Serial.printf("\nProvisioning Started with name "%s" and PoP "%s" on SoftAP\n", service_name, pop);
printQR(service_name, pop, "softap");

#endif
break;
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
Serial.printf("\nConnected to Wi-Fi!\n");
digitalWrite(wifiLed, true);
break;
}
}

void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
const char *device_name = device->getDeviceName();
const char *param_name = param->getParamName();

if(strcmp(device_name, deviceName_1) == 0) {
  
  Serial.printf("Lightbulb = %s\n", val.val.b? "true" : "false");
  
  if(strcmp(param_name, "Power") == 0) {
      Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
    toggleState_1 = val.val.b;
    (toggleState_1 == false) ? digitalWrite(RelayPin1, HIGH) : digitalWrite(RelayPin1, LOW);
    param->updateAndReport(val);
  }
  
} else if(strcmp(device_name, deviceName_2) == 0) {
  
  Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");

  if(strcmp(param_name, "Power") == 0) {
    Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
    toggleState_2 = val.val.b;
    (toggleState_2 == false) ? digitalWrite(RelayPin2, HIGH) : digitalWrite(RelayPin2, LOW);
    param->updateAndReport(val);
  }

} else if(strcmp(device_name, deviceName_3) == 0) {
  
  Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");

  if(strcmp(param_name, "Power") == 0) {
    Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
    toggleState_3 = val.val.b;
    (toggleState_3 == false) ? digitalWrite(RelayPin3, HIGH) : digitalWrite(RelayPin3, LOW);
    param->updateAndReport(val);
  }

} else if(strcmp(device_name, deviceName_4) == 0) {
  
  Serial.printf("Switch value = %s\n", val.val.b? "true" : "false");

  if(strcmp(param_name, "Power") == 0) {
    Serial.printf("Received value = %s for %s - %s\n", val.val.b? "true" : "false", device_name, param_name);
    toggleState_4 = val.val.b;
    (toggleState_4 == false) ? digitalWrite(RelayPin4, HIGH) : digitalWrite(RelayPin4, LOW);
    param->updateAndReport(val);
  }  
}  

}

void manual_control()
{
if (digitalRead(SwitchPin1) == LOW && SwitchState_1 == LOW) {
digitalWrite(RelayPin1, LOW);
toggleState_1 = 1;
SwitchState_1 = HIGH;
my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_1);
Serial.println("Switch-1 on");
}
if (digitalRead(SwitchPin1) == HIGH && SwitchState_1 == HIGH) {
digitalWrite(RelayPin1, HIGH);
toggleState_1 = 0;
SwitchState_1 = LOW;
my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_1);
Serial.println("Switch-1 off");
}
if (digitalRead(SwitchPin2) == LOW && SwitchState_2 == LOW) {
digitalWrite(RelayPin2, LOW);
toggleState_2 = 1;
SwitchState_2 = HIGH;
my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_2);
Serial.println("Switch-2 on");
}
if (digitalRead(SwitchPin2) == HIGH && SwitchState_2 == HIGH) {
digitalWrite(RelayPin2, HIGH);
toggleState_2 = 0;
SwitchState_2 = LOW;
my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_2);
Serial.println("Switch-2 off");
}
if (digitalRead(SwitchPin3) == LOW && SwitchState_3 == LOW) {
digitalWrite(RelayPin3, LOW);
toggleState_3 = 1;
SwitchState_3 = HIGH;
my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_3);
Serial.println("Switch-3 on");
}
if (digitalRead(SwitchPin3) == HIGH && SwitchState_3 == HIGH) {
digitalWrite(RelayPin3, HIGH);
toggleState_3 = 0;
SwitchState_3 = LOW;
my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_3);
Serial.println("Switch-3 off");
}
if (digitalRead(SwitchPin4) == LOW && SwitchState_4 == LOW) {
digitalWrite(RelayPin4, LOW);
toggleState_4 = 1;
SwitchState_4 = HIGH;
my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_4);
Serial.println("Switch-4 on");
}
if (digitalRead(SwitchPin4) == HIGH && SwitchState_4 == HIGH) {
digitalWrite(RelayPin4, HIGH);
toggleState_4 = 0;
SwitchState_4 = LOW;
my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, toggleState_4);
Serial.println("Switch-4 off");
}
}

void setup()
{
uint32_t chipId = 0;

Serial.begin(115200);

// Set the Relays GPIOs as output mode
pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);
pinMode(RelayPin3, OUTPUT);
pinMode(RelayPin4, OUTPUT);  
pinMode(wifiLed, OUTPUT);

// Configure the input GPIOs
pinMode(SwitchPin1, INPUT_PULLUP);
pinMode(SwitchPin2, INPUT_PULLUP);
pinMode(SwitchPin3, INPUT_PULLUP);
pinMode(SwitchPin4, INPUT_PULLUP);
pinMode(gpio_reset, INPUT);

// Write to the GPIOs the default state on booting
digitalWrite(RelayPin1, !toggleState_1);
digitalWrite(RelayPin2, !toggleState_2);
digitalWrite(RelayPin3, !toggleState_3);
digitalWrite(RelayPin4, !toggleState_4);
digitalWrite(wifiLed, LOW);

Node my_node;    
my_node = RMaker.initNode("ESP32_Relay_4");

//Standard switch device
my_switch1.addCb(write_callback);
my_switch2.addCb(write_callback);
my_switch3.addCb(write_callback);
my_switch4.addCb(write_callback);

//Add switch device to the node   
my_node.addDevice(my_switch1);
my_node.addDevice(my_switch2);
my_node.addDevice(my_switch3);
my_node.addDevice(my_switch4);

//This is optional 
RMaker.enableOTA(OTA_USING_PARAMS);
//If you want to enable scheduling, set time zone for your region using setTimeZone(). 
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai");
// Alternatively, enable the Timezone service and let the phone apps set the appropriate timezone
RMaker.enableTZService();
RMaker.enableSchedule();

//Service Name
for(int i=0; i<17; i=i+8) {
  chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}

Serial.printf("\nChip ID:  %d Service Name: %s\n", chipId, service_name);

Serial.printf("\nStarting ESP-RainMaker\n");
RMaker.start();

WiFi.onEvent(sysProvEvent);

#if CONFIG_IDF_TARGET_ESP32
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);

#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#endif

my_switch1.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
my_switch2.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
my_switch3.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);
my_switch4.updateAndReportParam(ESP_RMAKER_DEF_POWER_NAME, false);

}

void loop()
{
// Read GPIO0 (external button to reset device
if(digitalRead(gpio_reset) == LOW) { //Push button pressed
Serial.printf("Reset Button Pressed!\n");
// Key debounce handling
delay(100);
int startTime = millis();
while(digitalRead(gpio_reset) == LOW) delay(50);
int endTime = millis();

    if ((endTime - startTime) > 10000) {
      // If key pressed for more than 10secs, reset all
      Serial.printf("Reset to factory.\n");
      RMakerFactoryReset(2);
    } else if ((endTime - startTime) > 3000) {
      Serial.printf("Reset Wi-Fi.\n");
      // If key pressed for more than 3secs, but less than 10, reset Wi-Fi
      RMakerWiFiReset(2);
    }
}
delay(100);

if (WiFi.status() != WL_CONNECTED)
{
  //Serial.println("WiFi Not Connected");
 // digitalWrite(wifiLed, false);
  ledBlink();
}
else
{
  //Serial.println("WiFi Connected");
  digitalWrite(wifiLed, true);
}

manual_control();

}

void ledBlink(){
digitalWrite(wifiLed, true);
delay(300);
digitalWrite(wifiLed, false);
} `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Unable to reproduce With given information issue is unable to reproduce Type: Question Only question
Projects
Development

No branches or pull requests

6 participants