Home icon indicating copy to clipboard operation
Home copied to clipboard

Bluetooth support

Open homerokzam opened this issue 7 years ago â€ĸ 28 comments

Are you planning to support Bluetooth?

Thanks

homerokzam avatar Apr 18 '19 01:04 homerokzam

?

homerokzam avatar Jun 04 '19 00:06 homerokzam

Yes, it is something on the list, but not available out of the box yet. However, if you have a serial Bluetooth adapter, it is possible to write your own interactions in managed code (C#).

If you would like to discuss further, please use our discord channels. Although I will leave this request open for when it is implemented.

networkfusion avatar Jun 07 '19 10:06 networkfusion

I developed an app (ios and android) to communicate with devices that have BLE. I made it work on ESP32 developing in c++, but I don't know how to start writing the firmware in C # (using nanoframework).

I'm a software guy, and I have some difficulty understanding how the hardware works.

Below is part of the code I developed: main.cpp ...

void setup() { Serial.begin(9600);

// LED pinMode(LED, OUTPUT);

// BLE BLEDevice::init("ParkCodeKey Service"); BLEServer *pServer = BLEDevice::createServer();

// Service BLEService *pService = pServer->createService(SERVICE_UUID);

// LED Status BLECharacteristic *pLedStatusCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_STATUS_LED, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); pLedStatusCharacteristic->setCallbacks(new LedStatusCallbacks());

// LED Command BLECharacteristic *pLedCommandCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_COMMAND_LED, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE); pLedCommandCharacteristic->setCallbacks(new LedCommandCallbacks());

pService->start();

BLEAdvertising *pAdvertising = pServer->getAdvertising(); pAdvertising->start(); }

...

LedStatusCallbacks.hpp

class LedStatusCallbacks : public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { std::string value = pCharacteristic->getValue();

  if (value.length() > 0) {

... } };

homerokzam avatar Jul 30 '19 14:07 homerokzam

@homerokzam nanoFramework does not have support for BLE on ESP32. Because there isn't an API we can't help you on porting your code to C#.

Unless I'm missunderstanding your message and you are offering to start develop BLE support in ESP32 for nanoFramework. Please clarify.

For conversations suggest that you join our Discord community. Better suited for conversations! 😉

josesimoes avatar Jul 31 '19 11:07 josesimoes

At first I would like to use an api with BLE. I can help develop, but I have no hardware experience. This is my first hardware project and my background is in software.

I will access the Discord community.

Thanks.

homerokzam avatar Jul 31 '19 13:07 homerokzam

@homerokzam Are you still interested in this? I want to start adding BLE to ESP32.

Hassmann avatar Apr 21 '20 12:04 Hassmann

Yes, I'm interested. But I'm a software guy, not a hardware guy.

Thanks.

On 21 Apr 2020, at 09:11, Hassmann [email protected] wrote:

@homerokzam https://github.com/homerokzam Are you still interested in this? I want to start adding BLE to ESP32.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nanoframework/Home/issues/476#issuecomment-617140997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIT2WY4YHGJDTY4XYMZYLRNWEQHANCNFSM4HGY5ZAQ.

homerokzam avatar May 04 '20 08:05 homerokzam

â„šī¸ @Hassmann is working on this.

josesimoes avatar May 21 '20 09:05 josesimoes

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.

stale[bot] avatar Jul 20 '20 10:07 stale[bot]

In progress. Correct @Hassmann ?

josesimoes avatar Jul 20 '20 13:07 josesimoes

This is unfortunately not in progress anymore. I am stuck here.

The reasons are:

  1. The espressif native BT libraries are way too large to include them into a standard image.
  2. They are even too large for including them into a custom firmware without serious cropping.
  3. NimBLE would fit, but it relies on ESP-IDF 4, currently not supported by nF

The state of the work done is in:

https://github.com/Hassmann/lib-nanoFramework.Hardware.Esp32.Bluetooth https://github.com/Hassmann/nf-interpreter

If anyone wants to take over, I am happy to assist.

Hassmann avatar Aug 03 '20 14:08 Hassmann

This is unfortunately not in progress anymore. I am stuck here.

The reasons are:

  1. The espressif native BT libraries are way too large to include them into a standard image.
  2. They are even too large for including them into a custom firmware without serious cropping.
  3. NimBLE would fit, but it relies on ESP-IDF 4, currently not supported by nF

The state of the work done is in:

https://github.com/Hassmann/lib-nanoFramework.Hardware.Esp32.Bluetooth https://github.com/Hassmann/nf-interpreter

If anyone wants to take over, I am happy to assist.

So the answer is to support ESP-IDF 4? What about to use the Arduino library implementation for ESP?

danielmeza avatar Oct 07 '20 05:10 danielmeza

@danielmeza the Arduino library is build on top of the IDF, which would bring us to the same place. I'm afraid that this needs to wait until our build is migrated to IDF-4...

josesimoes avatar Oct 07 '20 10:10 josesimoes

@josesimoes I guest that too, can you point us to that task in order to help with the migration to IDF-4? Perhaps a check list with the pending's to reach IDF-4 migration?

danielmeza avatar Oct 07 '20 12:10 danielmeza

@danielmeza glad that you've asked! 😄

Migrating the IDF involves several steps. Here's a general overview of the process.

  • Recompiling the libraries. See here
  • Updating the various references to the new IDF version in the CMake files and PS scripts (in nf-interpreter repo)
  • Adjust calls to the IDF functions/API, if needed.

For details suggest the #native-esp32 channel on Discord. Also know that @AdrianSoundy is the ESP32 master.

josesimoes avatar Oct 07 '20 16:10 josesimoes

The latest nanoframework IDF update to v3.3.5 now includes the bluetooth component ready for a managed library to be built. This is based on Nimble. There were problems including bluetooth due to size especially as a lot of iram was used by the PSRAM fixes. So currently the is a bluetooth version without psram for version 1 ESP32. For Version 3 ESP32 it was not problem as psram fixes not required.

AdrianSoundy avatar Jul 22 '21 02:07 AdrianSoundy

For managed library we can either base the library from the UWP Windows.devices.Bluetooth or continue with the work done by @Hassmann. There are a lots of classes to implement in the UWP library, maybe we should create our own based on UWP but called System.Device.Bluetooth.

AdrianSoundy avatar Jul 22 '21 02:07 AdrianSoundy

For managed library we can either base the library from the UWP Windows.devices.Bluetooth or continue with the work done by @Hassmann. There are a lots of classes to implement in the UWP library, maybe we should create our own based on UWP but called System.Device.Bluetooth.

I would be pragmatic and use Syste.Device.Bluetooth, move any good work done previously and maybe just the first subset of necessary classes to start with.

Ellerbach avatar Jul 23 '21 10:07 Ellerbach

Started implementing Gatt classes but hit a blocker when looking to implement an event to managed code for gatt property changes read/write. The callbacks for nimble expects you to respond directly in callback for property changes not allowing event to be reflected to managed code

AdrianSoundy avatar Aug 09 '21 00:08 AdrianSoundy

@AdrianSoundy have you had any success with the Bluetooth library?

romarro avatar Sep 21 '21 18:09 romarro