-
Notifications
You must be signed in to change notification settings - Fork 158
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
ESP 32 BLE and SoftAP connection problem Rainmaker App Device not found (MEGH-3905) #184
Comments
HI @zakirox123, |
I tried with the latest ESP32-Arduino v2.0.5 and ESP32 DEVkit V1 |
don't know if you solved this problem i had this problem too but on esp32s |
no still no luck i am finding some alternative solutions |
Hi @zakirox123 , |
Hola Pudieron solucionar este problema?, tengo el mismo problema. |
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
`#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)
{
#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;
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();
}
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;
#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()
{
// 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();
}
void ledBlink(){
digitalWrite(wifiLed, true);
delay(300);
digitalWrite(wifiLed, false);
}`
The text was updated successfully, but these errors were encountered: