Skip to content

Conversation

@AdrianSoundy
Copy link
Member

@AdrianSoundy AdrianSoundy commented Aug 13, 2022

Description

Initial implementation of Bluetooth Central/Client.

This covers the base implementation for : -

  • Watching for Bluetooth Server devices
  • Creating a BluetoothLEDevice object for the device
  • Connecting & Discovering available services from device
  • Discovering available characteristics in a service
  • Discovering available descriptors in a characteristic
  • Read / Write to an attribute ( Characteristic/Descriptor)
  • Notify events for changes in attributes

See nanoFramework.Device.Bluetooth for full details/examples code

Currently no support for pairing/bonding and authentication. This will be in next PR

There is still a fair amount of commented/disabled code and you may also find some TODO comments

Motivation and Context

How Has This Been Tested?

Tested with sample code in separate PR. Will be available once main parts merges and nuget available.

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dev Containers (changes related with Dev Containers, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).

Bluetooth Central changes
nfbot and others added 7 commits August 13, 2022 04:43
Automated fixes for code style.
Automated fixes for code style.
…d-fdc7-4b24-8f81-b89cdb361030' into Bluetooth-central
…4-45e7-428f-a014-a99f4b066fd0' into Bluetooth-central
…d8c4-45e7-428f-a014-a99f4b066fd0

Code style fixes for nanoframework/nf-interpreter PR#2409
Automated fixes for code style.
…41fd-5e90-46e6-8a0c-c9072c25a8a2

Code style fixes for nanoframework/nf-interpreter PR#2409
@AdrianSoundy AdrianSoundy changed the title Bluetooth LE Central/Client implementation Initial Bluetooth LE Central/Client implementation Aug 13, 2022
@AdrianSoundy AdrianSoundy removed the request for review from alberk8 August 13, 2022 21:25
AdrianSoundy and others added 4 commits August 15, 2022 13:11
Automated fixes for code style.
…cb53-7219-4998-b9e4-87340ccbbc27

Code style fixes for nanoframework/nf-interpreter PR#2409
@josesimoes josesimoes added the Platform: ESP32 Everything related specifically with ESP32 platform label Aug 16, 2022
Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW!! Lot's of work here. Great job. 👏🏻
Just some minor changes requested. 😅

AdrianSoundy and others added 3 commits August 17, 2022 09:07
Also added some missing defines(no change to behaviour)
Automated fixes for code style.
@AdrianSoundy AdrianSoundy requested a review from alberk8 August 17, 2022 00:32
…e4dc-b618-4dd2-b1f1-2dffe83e54eb

Code style fixes for nanoframework/nf-interpreter PR#2409
Copy link
Contributor

@alberk8 alberk8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int map[16]{15, 14, 13, 12, 11, 10, 9, 8, 6, 7, 4, 5, 0, 1, 2, 3};

I need to change this so that custom uuid to Guid would work.
int map[16]{12, 13, 14, 15, 10, 11, 8, 9, 7, 6, 5, 4, 3, 2, 1, 0};

@AdrianSoundy
Copy link
Member Author

int map[16]{15, 14, 13, 12, 11, 10, 9, 8, 6, 7, 4, 5, 0, 1, 2, 3};

I need to change this so that custom uuid to Guid would work. int map[16]{12, 13, 14, 15, 10, 11, 8, 9, 7, 6, 5, 4, 3, 2, 1, 0};

Can you please explain where you are seeing a problem. I tried BluetoothLEDevcie.GetGattServices() and it returns correct UUID. Also the line you are changing is not called by anything so it won't make any difference. I made the GuidToNimbleUUID() method but didn't change the code to call it.
@alberk8

…00bf-2ca8-441a-add9-ed3159a13cb5

Code style fixes for nanoframework/nf-interpreter PR#2409
@alberk8
Copy link
Contributor

alberk8 commented Aug 19, 2022

int map[16]{15, 14, 13, 12, 11, 10, 9, 8, 6, 7, 4, 5, 0, 1, 2, 3};

I need to change this so that custom uuid to Guid would work. int map[16]{12, 13, 14, 15, 10, 11, 8, 9, 7, 6, 5, 4, 3, 2, 1, 0};

Can you please explain where you are seeing a problem. I tried BluetoothLEDevcie.GetGattServices() and it returns correct UUID. Also the line you are changing is not called by anything so it won't make any difference. I made the GuidToNimbleUUID() method but didn't change the code to call it. @alberk8

Sorry for pointing to the wrong line, it should be line 25 under the function NimbleUUID128ToGuid. Below is what I get from running the Ble Central and displaying the UUID of the services and Characteristic of the BluetoothLESample3. The incorrect one is only the Custom Services and Characteristics. The correct uuid should be

Guid serviceUuid = new Guid("A7EEDF2C-DA87-4CB5-A9C5-5151C78B0057");
Guid readStaticCharUuid = new Guid("A7EEDF2C-DA89-4CB5-A9C5-5151C78B0057");

image
@AdrianSoundy

AdrianSoundy and others added 6 commits August 20, 2022 16:46
nano Extension was added extra lines, upgraded extension
Automated fixes for code style.
…bc4b-5129-43dc-98b1-5cc05a4b084b

Code style fixes for nanoframework/nf-interpreter PR#2409
@AdrianSoundy AdrianSoundy removed the request for review from Ellerbach August 20, 2022 05:22
@AdrianSoundy
Copy link
Member Author

Looks like a good time to merge now. More things to be done but these can be done in next PR

@AdrianSoundy AdrianSoundy merged commit 7de2295 into nanoframework:main Aug 20, 2022
lsd-techno pushed a commit to lsd-techno/nf-interpreter that referenced this pull request Aug 20, 2022
@AdrianSoundy AdrianSoundy deleted the Bluetooth-central branch August 21, 2022 23:01
@bbhxwl
Copy link

bbhxwl commented Aug 25, 2022

If I scan, stop, connect the client, and continue scanning while connecting, will it affect the connected client? Because I want to connect five different Bluetooth client devices, but I'm not sure when they start up, so I need to scan regularly.

@josesimoes
Copy link
Member

@bbhxwl this is a question, nothing related with PR workflow. Can you please use our Discord server for these?

aromaa pushed a commit to aromaa/nf-interpreter that referenced this pull request Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: ESP32 Everything related specifically with ESP32 platform Type: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Central/Client capability to Bluetooth

5 participants