Comments (9)
Can you provide more specifics?
from what I can see, I am guessing that it is occuring in the WifiLoop function, it might be caused by not ending the previous mode before switching between Central and Peripheral
from ambd_arduino.
I call BLE.end() before switching.
I attach the whole sketch.
log of this code:
#calibration_ok:[2:19:11]`
interface 0 is initialized
interface 1 is initialized
Initializing WIFI ...
WIFI initialized
[BLE Device] Local BT addr: 70:1d:08:0c:06:0c
[BLE Device] GAP scan start
WiFi disconnected_
[BLE Device] GAP scan stop
Begin per...
```
[RL8722DMBridgeTest.zip](https://github.com/ambiot/ambd_arduino/files/5695752/RL8722DMBridgeTest.zip)
from ambd_arduino.
you are right, there was something blocking the peripheral mode.
attached are some new files that should fix the issue, make a copy of the old files, and replace with the fixed files in the libraries folder.
a few points I noticed regarding the rest of the code:
- advertising data will be lost after calling BLE.end(), so you will need to reconfigure advertising data after switching to peripheral mode
- after connecting the board to wifi, the smartphone app used for WiFi config will remain connected until the user accepts the settings or quit the app, so it is not possible for the board to switch back to central mode immediately after connecting to wifi. Another criteria should be used to determine when to stop peripheral mode and switch to central mode, perhaps check if the board is still connected to a device before calling BLE.end and switching modes.
from ambd_arduino.
Thank you for cooperation. I also want to note that the BLE.end() needs internal blocking and synchronization. Now we have to add delays when switching from scan mode to peripheral:
BLE.configScan()->stopScan();
delay(5000);
BLE.end();
from ambd_arduino.
can you clarify on the internal blocking and synchronization?
do you mean BLE.end() should stop scans when called?
from ambd_arduino.
I meant that BLE.end () should wait for the completion of the stop scan operation, or stopScan () should do it. Anyway, without delay (5000) this code does not work, this is not the correct behavior
from ambd_arduino.
I have done some testing and could not replicate the behavior. From what I can see, the code still works without the delay(5000).
Here is the code snippet:
if (WiFi.status() != WL_CONNECTED)
{
Serial.println("WiFi disconnected");
connecting_flag = 1;
Serial.println("Stop scan");
BLE.configScan()->stopScan();
BLE.end();
Serial.println("BLE end");
Serial.println("Begin peripheral");
BLE.beginPeripheral();
Serial.println("Start adv");
BLE.configAdvert()->startAdv();
}
and here is the log output:
15:45:47.136 -> [BLE Device] GAP scan start
15:45:47.136 -> Scan Data 1
15:45:47.136 -> Scan Data 2
15:45:47.136 -> Scan Data 3
15:45:47.182 -> Scan Data 4
15:45:47.228 -> WiFi disconnected
15:45:47.228 -> Stop scan
15:45:47.228 -> BLE end
15:45:47.228 -> Begin peripheral
15:45:47.228 -> Adv update
15:45:47.228 -> GAP cb reg
15:45:47.228 -> Task create
15:45:47.228 -> Coex init
15:45:47.228 -> BT stack start
15:45:47.228 -> gapMsgHandlerDefault: subtype 1
15:45:47.228 -> devStateEvtHandlerPeriphDefault: init state 1, adv state 0, cause 0x0
15:45:47.228 -> Coex on
15:45:47.321 -> Start adv
from ambd_arduino.
Indeed, apparently I ran the code before the fix.
Yes, everything works without delay.
from ambd_arduino.
That is good to hear, thanks for the your feedback
from ambd_arduino.
Related Issues (20)
- Pinout LED blue (BW16 RTL8720DN) HOT 3
- mDNS service discovery HOT 3
- [MicroPython feature request] WiFi scan improve. HOT 3
- Compatibility issue: AMB26(RTL8720DF) and NORA-W30(RTL8720DF) share same #defined(BOARD_RTL8720DF). HOT 3
- Permission denied when compiling on Linux HOT 4
- Compile fails on Windows if space exists in path (eg username) HOT 4
- [Question] How to install amb-D board using release .zip file? HOT 2
- Send raw ieee80211 data HOT 3
- Expose WiFi channel in WiFi.scanNetworks() and update example to showcase usage HOT 5
- I confirm I have checked existing/closed list of issues and the Contributing Guide.
- Spelling mistakes (GitHub Action Spell Check) HOT 4
- AMB25 and AMB26 upload issues HOT 2
- Documentation/instructions/support files for how to rebuild the libraries in "variants/common_libs" (source in system) HOT 6
- Error compiling for board Ai-Thinker BW16 (RTL8720DN) HOT 3
- UDP.h is missing in core HOT 2
- The SPI.h file error HOT 3
- BW16 MQTT can't use ArduinoJSON.h HOT 2
- Would it be possible to add enterprise wifi (PEAP-MSCHAPv2) support HOT 2
- SPI dataMode not updating correctly in SPIClass::beginTransaction() HOT 3
- WS2812B fails with multiple calls to show() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ambd_arduino.