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

Override max num BLE connections to allow up to 5 connections #82

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

giulcioffi
Copy link
Contributor

This patch will allow to connect up to 5 BLE peripherals to a BLE central device. It will take effect at the next core compilation, where DM_CONN_MAX will be set to 5 (now it is 3).
This will fix ArduinoBLE#116 and ArduinoCore-nRF528#40.

@iactiva
Copy link

iactiva commented Oct 31, 2020

I've been unable to connect to more than 2-3 peripherals including th patch. It connects up to two devices and have problems to connect to the 3rd device about 50% of times.
Can anyone confirm connection to 5 peripherals in central mode? Or even preferred up to 8 as said other forks/branches

@giulcioffi
Copy link
Contributor Author

Hi @iactiva,
did you recompile the core with this patch before doing your tests? For instance, when you will compile for Arduino Nano 33 BLE, the value of this define will change.
Moreover, you need to apply the patches from this PR in ArduinoBLE library, otherwise you will not be able to connect more than 2 devices.

@iactiva
Copy link

iactiva commented Nov 2, 2020

Hi @giulcioffi,
Yes, I've applied all patches to the BLE library however I've noticed I'm getting multiple errors while compiling.
I'm using the provided script with latest ArduinoCore-mbed version as follows:
./mbed-os-to-arduino -c -a ARDUINO_NANO33BLE:ARDUINO_NANO33BLE

Here is a portion of the output. Maybe you can find what may be wrong here.

[mbed] ERROR: "/usr/bin/python3" returned error.
       Code: 1
       Path: "/tmp/mbed-os-program"
       Command: "/usr/bin/python3 -u /tmp/mbed-os-program/mbed-os/tools/make.py -t GCC_ARM -m ARDUINO_NANO33BLE --source . --build ./BUILD/ARDUINO_NANO33BLE/GCC_ARM -v"
---
Building project mbed (ARDUINO_NANO33BLE, GCC_ARM)
Scan: mbed
Macros: -DDEVICE_USBDEVICE=1 -DTARGET_SDK_15_0 -DARM_MATH_CM4 -DDEVICE_PORTINOUT=1 -DTARGET_SOFTDEVICE_NONE -DDEVICE_I2CSLAVE=1 -D__CORTEX_M4 -DDEVICE_I2C=1 -DTARGET_CORTEX -DTARGET_RELEASE -DTARGET_NRF52840 -DNRF52_PA>
Compile [  0.8%]: PluggableUSBDevice.cpp
Compile: arm-none-eabi-g++ -c -std=gnu++14 -fno-rtti -Wvla -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -ffunction-sections -fdata-sections -funsigned-char -MMD>
[Error] lwipopts.h@34,2: #error "Either IPv4 or IPv6 must be enabled."
[Error] lwipopts.h@71,2: #error "Either IPv4 or IPv6 must be preferred."
[Error] string_conversions.h@63,27: 'errno' was not declared in this scope
[Error] string_conversions.h@64,23: 'errno' was not declared in this scope
[Error] string_conversions.h@84,16: 'errno' was not declared in this scope
[Error] error_constants.h@122,27: 'ENOTSUP' was not declared in this scope
[Error] CThunkBase.h@59,43: 'MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX' was not declared in this scope
[Error] CThunkBase.h@64,39: 'MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX' was not declared in this scope
[Error] CThunkBase.h@82,9: '_thunk_storage' was not declared in this scope
[Error] UnbufferedSerial.h@66,20: 'MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE' was not declared in this scope
[Error] UnbufferedSerial.h@77,20: 'MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE' was not declared in this scope
[Error] BufferedSerial.h@69,20: 'MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE' was not declared in this scope
[Error] BufferedSerial.h@80,20: 'MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE' was not declared in this scope
[Error] ctime@64,11: '::clock' has not been declared
[Error] ctime@65,11: '::difftime' has not been declared
[Error] ctime@66,11: '::mktime' has not been declared
[Error] ctime@67,11: '::time' has not been declared
[Error] ctime@68,11: '::asctime' has not been declared
[Error] ctime@69,11: '::ctime' has not been declared
[Error] ctime@70,11: '::gmtime' has not been declared
[Error] ctime@71,11: '::localtime' has not been declared
[Error] ctime@72,11: '::strftime' has not been declared
[Error] pins_arduino.h@69,22: 'const uint8_t A0' redeclared as different kind of entity
[Error] pins_arduino.h@70,22: 'const uint8_t A1' redeclared as different kind of entity
[Error] pins_arduino.h@71,22: 'const uint8_t A2' redeclared as different kind of entity
[Error] pins_arduino.h@72,22: 'const uint8_t A3' redeclared as different kind of entity
[Error] pins_arduino.h@73,22: 'const uint8_t A4' redeclared as different kind of entity
[Error] pins_arduino.h@74,22: 'const uint8_t A5' redeclared as different kind of entity
[Error] pins_arduino.h@75,22: 'const uint8_t A6' redeclared as different kind of entity
[Error] pins_arduino.h@76,22: 'const uint8_t A7' redeclared as different kind of entity
[Error] mbed_rtos_types.h@51,32: 'osOK' conflicts with a previous declaration
[Error] mbed_rtos_types.h@52,32: 'osError' conflicts with a previous declaration
[Error] mbed_rtos_types.h@53,32: 'osErrorTimeout' conflicts with a previous declaration
[Error] mbed_rtos_types.h@54,32: 'osErrorResource' conflicts with a previous declaration
[Error] mbed_rtos_types.h@55,32: 'osErrorParameter' conflicts with a previous declaration
[Error] mbed_rtos_types.h@56,32: 'osErrorNoMemory' conflicts with a previous declaration
[Error] mbed_rtos_types.h@57,32: 'osErrorISR' conflicts with a previous declaration
[Error] mbed_rtos_types.h@58,31: 'osStatusReserved' conflicts with a previous declaration
[Error] mbed_rtos_types.h@59,3: conflicting declaration 'typedef enum osStatus_t osStatus_t'
[Error] PluggableUSBSerial.h@261,11: 'Thread' in namespace 'rtos' does not name a type; did you mean 'ThisThread'?
...

My system is: ubuntu 20 | python v3.8.5 | mbed-cli v1.10.4 | arm-none-eabi-gcc v9.2.1

Thank you

@giulcioffi
Copy link
Contributor Author

Hi @iactiva,
first of all you should specify the mbed-os version that you are using. Try to use:

  • ArduinoCore-mbed @ master
  • mbed-os @ portenta-mbed-6.2.0
  • ArduinoCore-API @ namespace_arduino
    You should have all these 3 folders as subdirectories of the same one.
    Make sure that the variable GCC_ARM is set with the path of your gcc compiler and that the same path is also specified in PATH.
    Then, inside you folder of ArduinoCore-mbed, run
    ./mbed-os-to-arduino -r ...full-path-to-mbed-os ARDUINO_NANO33BLE:ARDUINO_NANO33BLE

@iactiva
Copy link

iactiva commented Nov 4, 2020

Many thanks @giulcioffi!
My fault was using the bundled mbed path under cores/arduino instead of portenta-mbed-6.2.0. That solved the issues and it compiles properly without errors.

Now I'm having other issues as compiling ArduinoCore-mbed "as is" for ARDUINO_NANO33BLE generates a libmbed.a file of 70MB instead the expected 57MB. Then adding it the the IDE, it allows any sketch to be compiled and uploaded to the 33BLE board however it is totally unstable, serial monitor simply hangs and even the LED brightness goes low when BLE.begin()...
I'd appreciate any help with this.

UPDATE: Well, issues come if setting more than 5 in cordio max-connections in conf/mbed_app.json
It is working for 5 peripherals, even after re-compiling and using my 70MB libmbed.a version, however it does not work for hight number. I've tried increasing STACK_SIZE values as suggested elsewhere w/o success...
The reason is explained here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow more than 3 concurrent peripheral connections in central mode
3 participants