adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
598 stars 488 forks source link

Bluetooth 5 Long Range support #82

Open hathach opened 6 years ago

hathach commented 6 years ago

ref https://www.nordicsemi.com/eng/Products/Bluetooth-5 ref https://www.novelbits.io/bluetooth-5-speed-maximum-throughput/

Update 1: iOS 13.4 could enable long range feature on compatible device https://www.reddit.com/r/iOSBeta/comments/fcww2x/feature_ios_134_beta_enables_ble_long_range/

Update 2: advertising on Coded PHY https://devzone.nordicsemi.com/f/nordic-q-a/49799/issue-regarding-nrf52840-long-range-mode

Update 3: SDK example is ble_app_att_mtu_throughput

Update 4: nRF Connect App on Android support seem to support Long Range already !!

Update : list of mobile device that is known to support Long Range, source https://devzone.nordicsemi.com/f/nordic-q-a/33060/is-there-any-smartphone-with-supporting-of-bluetooth-5-long-range-feature/221305#221305

Apple Iphone XS
Apple Iphone XS MAX
Apple Iphone XR
Apple Iphone 11
Apple Iphone 11 PRO
Apple Iphone 11 PRO MAX

Samsung Galaxy S10
Samsung Galaxy S10E
Samsung Galaxy S10+
Samsung Galaxy Note 10
Samsung Galaxy Note 10 PLUS
Samsung Galaxy Fold 

OnePlus 6
OnePlus 7 
OnePlus 7 PRO

Google Pixel 4 XL 
Google Pixel 4 

Huawei P30
Huawei P30 Pro
Huawei Mate 20
Huawei Mate 20 Pro

Edit:

Xiaomi Mi 9
lefedor commented 6 years ago

https://www.nordicsemi.com/eng/Products/Bluetooth-5 Have interest in this myself. Want mention that long range is not in the nRF52832 feature list, only for the nRF52840.

hathach commented 5 years ago

@lefedor nrf52840 is coming to Adafruit store soon enough :D

mharper commented 5 years ago

I have a relatively immediate need for this feature and have a nRF52840 Feather landing here in a few days. @hathach if you can give me a vector or two on how to implement this, I can do it.

hathach commented 5 years ago

This is new to me as well, you need to dive into Nordic docs and code to get it work. Please let us know what you figure out.

mharper commented 5 years ago

Acknowledged. Will let you know what I find out.

mharper commented 5 years ago

Based on what I've pieced together so far, the best example of how to do this is in the nRF SDK example found here:

examples/ble_central_and_peripheral/experimental/ble_app_att_mtu_throughput

Relevant struct: ble_gap_phys_t Therein lie: tx_phys and rx_phys. The value to use there for extended range appears to be BLE_GAP_PHY_CODED. Relevant API call: sd_ble_gap_phy_update

So in the context of bluefruit.cpp, I imagine the call might look like this to set the PHY:

bool AdafruitBluefruit::setPhy(int8_t phy) {
  ble_gap_phys_t phys;
  phys.tx_phys = phy;
  phys.rx_phys = phy;
  VERIFY_STATUS( sd_ble_gap_phy_update(_conn_hdl, &phys), false );
  return true;
}

Enabling extended range would then look like:

Bluefruit.setPhy(BLE_GAP_PHY_CODED);

You can set the PHY to any one of:

syed93uthman commented 5 years ago

this feature will help in my project alot. Thanks

hathach commented 5 years ago

@mharper thank you very much for your findings. I will do some simple tests here, but currently occupied by usb work.

jps2000 commented 5 years ago

any chance of progress here? thanks

ladyada commented 5 years ago

@jps2000 no ETA

mharper commented 5 years ago

Sorry, folks. I was able to solve my problem by cranking up the tx power, so I haven't revisited this.

hathach commented 5 years ago

@mharper you have nothing to sorry about 😉😉. We are busy with usb as well. Also long range need a bit of field testing imho. We are in no hurry, still lots of other work to do.

ApoorvaSheth commented 4 years ago

I want to test the long range of Adafruit nRF52840 express feather(BLE 5.0) board. I did the setup on arduino IDE. My question is can I perform the long range test of BLE using an arduino ide on adafruit nRF52840 express feather board?

hathach commented 4 years ago

The feature is not yet implemented.

ladyada commented 4 years ago

@ApoorvaSheth the answer is above, if you post spam or nags again, you will get blocked

orhanyor commented 4 years ago

this would be a good addition, i was looking how to add pa lna to 52840s to improve the range but long range support might be a better and neater solution.

path9263 commented 4 years ago

I am curious if someone can roughly outline what else is required to get this working. I have some time to try get it going but am unsure where to start. Thanks!

hathach commented 4 years ago

I am curious if someone can roughly outline what else is required to get this working. I have some time to try get it going but am unsure where to start. Thanks!

You probably need to advertise and connect using CODED PHY, check out articles in my 1st post, nordic devzone and sdk are a good source of reference.

vladkozlov69 commented 4 years ago

@path9263 you can find some ideas in my fork where I added some very basic implementation for long range, see https://github.com/vladkozlov69/Adafruit_nRF52_Arduino/pull/17/commits

path9263 commented 4 years ago

@vladkozlov69 thanks for that, very helpful. I feel like I am pretty close but I am wondering if you overcame the problem I am having. My central sees my peripheral advertising on Coded Phy and attempts to connect but the central fails and reports: bool BLECentral::connect(const ble_gap_addr_t*): 78: verify failed, error = NRF_ERROR_RESOURCES which seems to point to setting a larger value for _sd_cfg.central.event_len. Tried several values and not having any luck with that though, same error. I see you added uint32_t _ram_start; to bluefruit.h but couldn't find it used anywhere and am wondering if that has something to do with this. I do not get an error about SoftDevice config requires more SRAM though. Thanks!

vladkozlov69 commented 4 years ago

@path9263 I had the similar issue with NRF_ERROR_RESOURCES, and when I increased the event_len, it has gone. Usually, Coded Phy requires bigger event_len than a regular connection.

Colas-Lepoutre commented 4 years ago

Hi, I was wondering if there were any news about the long range feature. I basically only need to have a "setPhy" function in order to make the device advertise and connect using phy coded. Is this something easily feasable ? Did you already get this working ?

Thanks in advance, Colas LEPOUTRE

gernot1972 commented 3 years ago

Is there any example code for read/write characteristics with Coded PHY enabled via arduino IDE?

maziarzamani commented 2 years ago

Anyone tried to test this on iOS 15?

bfribush commented 2 years ago

Has the Coded PHY feature been implemented?