GithubHelp home page GithubHelp logo

Support L2CAP about esp32-nimble HOT 6 OPEN

milewski avatar milewski commented on August 23, 2024
Support L2CAP

from esp32-nimble.

Comments (6)

taks avatar taks commented on August 23, 2024

There are no immediate plan to support l2cap.
PR is welcome.

from esp32-nimble.

taks avatar taks commented on August 23, 2024

I have implemented a simple feature of L2CAP.
Are there any additional functions required?

from esp32-nimble.

milewski avatar milewski commented on August 23, 2024

To be honest, I don't really understand how it works. I was trying to connect a Sony controller to an ESP32, and I found that it communicates via L2CAP. My first attempt was trying to use this library, but it didn't work.

Then, in the end, I found a reference code here in C (https://github.com/jvpernis/esp32-ps3/blob/master/src/ps3.c), and since it calls the ESP-IDF framework, I was able to translate the C code to unsafe Rust more or less one-to-one and get the controller working.

Certainly, it would have been much simpler and easier if I could have done all the integration directly with this library. Much of the initialization code was mostly copy/pasted from here:

if !INITIALIZED {
let result = esp_idf_sys::nvs_flash_init();
if result == esp_idf_sys::ESP_ERR_NVS_NO_FREE_PAGES
|| result == esp_idf_sys::ESP_ERR_NVS_NEW_VERSION_FOUND
{
::log::warn!("NVS initialisation failed. Erasing NVS.");
esp_nofail!(esp_idf_sys::nvs_flash_erase());
esp_nofail!(esp_idf_sys::nvs_flash_init());
}
esp_idf_sys::esp_bt_controller_mem_release(
esp_idf_sys::esp_bt_mode_t_ESP_BT_MODE_CLASSIC_BT,
);
#[cfg(esp_idf_version_major = "4")]
esp_nofail!(esp_idf_sys::esp_nimble_hci_and_controller_init());
esp_idf_sys::nimble_port_init();
esp_idf_sys::ble_hs_cfg.sync_cb = Some(Self::on_sync);
esp_idf_sys::ble_hs_cfg.reset_cb = Some(Self::on_reset);
// Set initial security capabilities
esp_idf_sys::ble_hs_cfg.sm_io_cap = esp_idf_sys::BLE_HS_IO_NO_INPUT_OUTPUT as _;
esp_idf_sys::ble_hs_cfg.set_sm_bonding(0);
esp_idf_sys::ble_hs_cfg.set_sm_mitm(0);
esp_idf_sys::ble_hs_cfg.set_sm_sc(1);
esp_idf_sys::ble_hs_cfg.sm_our_key_dist = 1;
esp_idf_sys::ble_hs_cfg.sm_their_key_dist = 3;
esp_idf_sys::ble_hs_cfg.store_status_cb = Some(esp_idf_sys::ble_store_util_status_rr);
ble_store_config_init();
esp_idf_sys::nimble_port_freertos_init(Some(Self::blecent_host_task));

from esp32-nimble.

taks avatar taks commented on August 23, 2024

The ps3 controller does not seem to use BLE communication, but bluetooth classic communication.
Unfortunately, the nimble library is available for BLE only, so it cannot be used for communication with ps3 controllers.

from esp32-nimble.

milewski avatar milewski commented on August 23, 2024

Yeah, that was what I found as well. None of the newer ESP chips worked either because they don't support classic Bluetooth. Only an old ESP32 worked out.

I have ordered a ps5 controller which does support BLE, I found this: https://github.com/rodneybakiskan/ps5-esp32 once I get the controller I will try to port the classic code to the ble version and see how it goes.. l2cap still required

from esp32-nimble.

taks avatar taks commented on August 23, 2024

The ps5 controller also seem to use bluetooth classic communication.
https://bluepad32.readthedocs.io/en/latest/supported_gamepads/#bluetooth-gamepads-and-their-protocol

from esp32-nimble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.