hi, i try to utilize BLE and Wifi server, but ig i start BLE server i have a loop of reset withi this error.
in serial monitor i have only
rst:0x3 (SW_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:0x3fff0018,len:4
load:0x3fff001c,len:1496
load:0x40078000,len:8596
load:0x40080400,len:6980
entry 0x400806f4
ets Jun 8 2016 00:22:57
Help me
i have enable all but i have the same result. In srial monitorl i see a loop of rst:0x3 (SW_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:0x3fff0018,len:4
load:0x3fff001c,len:1496
load:0x40078000,len:8596
load:0x40080400,len:6980
entry 0x400806f4
ets Jun 8 2016 00:22:57
I think than my sket not start; if i comment intible or all call of Wifi library , i havne't problem but if i use all together i have reboot loop on start
Then it has nothing to do with ble and wifi. If there is nothing more in logs, then your code is causing reboot even before wifi or ble starts.
i attach pmy code: PS i rean douring my compilation there are many arning: 'LOG_TAG' defined but not used [-Wunused-variable].
PS. i have a borad jzk esp32s what kind of board i can select?
now i try if i sue nodemcu32s work if i use ep32 dev module thi sketch go in loop reboot.
// Default Arduino includes
// Includes for JSON object handling
// Requires ArduinoJson library
// https://arduinojson.org
// https://github.com/bblanchon/ArduinoJson
//#include
// Includes for BLE
#include "esp32-hal-log.h"
int loc_HIGH = HIGH;
int loc_LOW = LOW;
/*
char lettura[BUFSIZE];
char master[BUFSIZE];
char slave[BUFSIZE];
*/
const int RELAY_PIN_1 = 12;
const int RELAY_PIN_2=14;
/** Build time */
const char compileDate[] = __DATE__ " " __TIME__;
/* Unique device name */
char apName[] = "ESP32-xxxxxxxxxxxx";
/* Selected network
true = use primary network
false = use secondary network
/
bool usePrimAP = true;
/* Flag if stored AP credentials are available /
bool hasCredentials = false;
/* Connection status /
volatile bool isConnected = false;
/* Connection change status /
bool connStatusChanged = false;
bool ElaborazioneIncorso=false;
/*
// List of Service and Characteristic UUIDs
//#define SERVICE_UUID "0000aaaa-ead2-11e7-80c1-9a214cf093ae"
/* SSIDs of local WiFi networks */
String ssidPrim;
String ssidSec;
/* Password for local WiFi network */
String pwPrim;
String pwSec;
/* Characteristic for digital output */
BLECharacteristic *pCharacteristicWiFi;
/* BLE Advertiser /
BLEAdvertising pAdvertising;
/* BLE Service */
BLEService *pService;
/* BLE Server */
BLEServer *pServer;
/**
void onDisconnect(BLEServer* pServer) {
Serial.println("BLE client disconnected");
pAdvertising->start();
}
};
/**
// Decode data
int keyIndex = 0;
for (int index = 0; index < value.length(); index ++) {
value[index] = (char) value[index] ^ (char) apName[keyIndex];
keyIndex++;
if (keyIndex >= strlen(apName)) keyIndex = 0;
}
};
void onRead(BLECharacteristic *pCharacteristic) {
Serial.println("BLE onRead request");
String wifiCredentials;
}
};
/**
// Create BLE Server
pServer = BLEDevice::createServer();
// Set server callbacks
pServer->setCallbacks(new MyServerCallbacks());
// Create BLE Service
pService = pServer->createService(BLEUUID(SERVICE_UUID),20);
// Create BLE Characteristic for WiFi settings
pCharacteristicWiFi = pService->createCharacteristic(
BLEUUID(WIFI_UUID),
// WIFI_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
| BLECharacteristic::PROPERTY_WRITE_NR| BLECharacteristic::PROPERTY_NOTIFY
);
pCharacteristicWiFi->setCallbacks(new MyCallbackHandler());
// Start the service
pService->start();
// Start advertising
pAdvertising = pServer->getAdvertising();
pAdvertising->start();
}
/** Callback for receiving IP address from AP */
void gotIP(system_event_id_t event) {
isConnected = true;
connStatusChanged = true;
}
// Callback for connection loss
void lostCon(system_event_id_t event) {
isConnected = false;
connStatusChanged = true;
}
/**
scanWiFi
Scans for available networks
and decides if a switch between
allowed networks makes sense
@return bool
True if at least one allowed network was found
/
bool scanWiFi() {
/* RSSI for primary network /
int8_t rssiPrim=-1;
/* RSSI for secondary network /
int8_t rssiSec=-1;
/* Result of this function */
bool result = false;
Serial.println("Start scanning for networks");
WiFi.disconnect(true);
WiFi.enableSTA(true);
WiFi.mode(WIFI_STA);
// Scan for AP
int apNum = WiFi.scanNetworks(false,true,false,1000);
if (apNum == 0) {
Serial.println("Found no networks?????");
return false;
}
byte foundAP = 0;
bool foundPrim = false;
for (int index=0; index
Serial.println("Found AP: " + ssid + " RSSI: " + WiFi.RSSI(index));
if (!strcmp((const char) &ssid[0], (const char) &ssidPrim[0])) {
Serial.println("Found primary AP");
foundAP++;
foundPrim = true;
rssiPrim = WiFi.RSSI(index);
}
if (!strcmp((const char) &ssid[0], (const char) &ssidSec[0])) {
Serial.println("Found secondary AP");
foundAP++;
rssiSec = WiFi.RSSI(index);
}
}
switch (foundAP) {
case 0:
result = false;
break;
case 1:
if (foundPrim) {
usePrimAP = true;
} else {
usePrimAP = false;
}
result = true;
break;
default:
Serial.printf("RSSI Prim: %d Sec: %dn", rssiPrim, rssiSec);
if (rssiPrim > rssiSec) {
usePrimAP = true; // RSSI of primary network is better
} else {
usePrimAP = false; // RSSI of secondary network is better
}
result = true;
break;
}
return result;
}
/**
WiFi.disconnect(true);
WiFi.enableSTA(true);
WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Start connection to ");
if (usePrimAP) {
Serial.println(ssidPrim);
WiFi.begin(ssidPrim.c_str(), pwPrim.c_str());
} else {
Serial.println(ssidSec);
WiFi.begin(ssidSec.c_str(), pwSec.c_str());
}
}
void setup() {
// Create unique device name
//createName();
// Initialize Serial port
Serial.begin(115200);
esp_log_level_set("*", ESP_LOG_VERBOSE);
log_v("Verbose");
log_d("Debug");
log_i("Info");
log_w("Warning");
log_e("Error");
// Send some device info
Serial.print("Build: ");
Serial.println(compileDate);
//connectWiFi();
String invert="";
Preferences preferences;
preferences.begin("Generale", false);
invert=preferences.getString("reverse","0");
preferences.end();
Serial.println("invert "+ invert);
if (invert[0] == '1') {
loc_HIGH = LOW;
loc_LOW = HIGH;
}
pinMode(RELAY_PIN_1, OUTPUT);
pinMode(RELAY_PIN_2, OUTPUT);
digitalWrite(RELAY_PIN_1, loc_LOW);
digitalWrite(RELAY_PIN_2, loc_LOW);
//TODO Preferences preferences;
preferences.begin("WiFiCred", false);
bool hasPref = preferences.getBool("valid", false);
if (hasPref) {
ssidPrim = preferences.getString("ssidPrim","");
ssidSec = preferences.getString("ssidSec","");
pwPrim = preferences.getString("pwPrim","");
pwSec = preferences.getString("pwSec","");
if (ssidPrim.equals("")
|| pwPrim.equals("")
|| ssidSec.equals("")
|| pwPrim.equals("")) {
Serial.println("Found preferences but credentials are invalid");
} else {
Serial.println("Read from preferences:");
Serial.println("primary SSID: "+ssidPrim+" password: "+pwPrim);
Serial.println("secondary SSID: "+ssidSec+" password: "+pwSec);
hasCredentials = true;
}
} else {
Serial.println("Could not find preferences, need send data over BLE");
}
preferences.end();
// Start BLE server
initBLE();
/*
if (hasCredentials) {
// Check for available AP's
if (!scanWiFi()) {
Serial.println("Could not find any AP");
} else {
// If AP was found, start connection
connectWiFi();
}
}*/
}
void loop() {
if (connStatusChanged) {
if (isConnected) {
Serial.print("Connected to AP: ");
Serial.print(WiFi.SSID());
Serial.print(" with IP: ");
Serial.print(WiFi.localIP());
Serial.print(" RSSI: ");
// Serial.println(WiFi.RSSI());
delay(5000);
//
delay(5000);
} else {
if (hasCredentials) {
Serial.println("Lost WiFi connection");
// Received WiFi credentials
if (!scanWiFi()) { // Check for available AP's
Serial.println("Could not find any AP");
} else { // If AP was found, start connection
connectWiFi();
}
}
}
connStatusChanged = false;
}
}
#define SERVICE_UUID "0000ffe0-0000-1000-8000-00805f9b34fb" // UART service UUID
#define CHARACTERISTIC_UUID_RX "0000ffe0-0000-1000-8000-00805f9b34fb"
#define CHARACTERISTIC_UUID_TX "0000ffe0-0000-1000-8000-00805f9b34fb"
Each UUID must unique. Try
#define SERVICE_UUID "0000ffe0-0000-1000-8000-00805f9b34fb" // UART service UUID
#define CHARACTERISTIC_UUID_RX "0000ffe1-0000-1000-8000-00805f9b34fb"
#define CHARACTERISTIC_UUID_TX "0000ffe2-0000-1000-8000-00805f9b34fb"
The binary size of the firmware might exceed the size of the app partition. BT increases the firmware by at least 600K. make sure it fits.
Can i make one partition with one app?
Inviato da iPhone
Il giorno 4 nov 2018, alle ore 14:17, Clemens Kirchgatterer notifications@github.com ha scritto:
The binary size of the firmware might exceed the size of the app partition. BT increases the firmware by at least 600K. make sure it fits.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I don't know if this was the OP's issue, but the symptoms above closely align with my issues so I figured I'd post here. My code would run fine with WiFi or BLE commented out, but when I had both I would get the same output described above.
My problem was that I didn't completley configure partitions correctly. I updated my boards.txt to properly account for my program size, but was still pointing to the default partition table (as opposed to the new one I created). This basically meant that my program overran the partition (or that it was only partially written, not sure how that is handled by the uploader). In any case, it basically meant part of my code wasn't accessible, so when it started up, it immediately crashed (which really confused me for a while, because it wasn't clearly crashing when it hit any particular line).
To @gigirizzi's question, yes you can. You need to change 2 files:
A few things to note:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This stale issue has been automatically closed. Thank you for your contributions.
Most helpful comment
I don't know if this was the OP's issue, but the symptoms above closely align with my issues so I figured I'd post here. My code would run fine with WiFi or BLE commented out, but when I had both I would get the same output described above.
My problem was that I didn't completley configure partitions correctly. I updated my boards.txt to properly account for my program size, but was still pointing to the default partition table (as opposed to the new one I created). This basically meant that my program overran the partition (or that it was only partially written, not sure how that is handled by the uploader). In any case, it basically meant part of my code wasn't accessible, so when it started up, it immediately crashed (which really confused me for a while, because it wasn't clearly crashing when it hit any particular line).
To @gigirizzi's question, yes you can. You need to change 2 files:
A few things to note: