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

Bounty - Bluetooth support using the Pico W #247

Open
2 tasks
Fortinbra opened this issue May 13, 2023 · 28 comments
Open
2 tasks

Bounty - Bluetooth support using the Pico W #247

Fortinbra opened this issue May 13, 2023 · 28 comments

Comments

@Fortinbra
Copy link
Contributor

Fortinbra commented May 13, 2023

We would like to have support for Bluetooth and the Pico W board.

Requirements

  • MUST maintain USB compatibility

  • MUST support at least X-Input modes via Bluetooth.

We need to still be able to use the controller as a USB controller when plugged in, or a Bluetooth controller when not.

This is purely from the firmware perspective. Hardware for battery management and charging will be a separate effort.

Addition Considerations

Would be nice to have.

@TheTrainGoes
Copy link
Contributor

We chatted about this and are going to break it down into two separate bounties.

Part 1 will be a proof of concept. This proof of concept is an MVP to see if it is even viable as a controller and has reasonable lag / performance / etc.

This part can be quick and easy.

Part 2 will be the full incorporation into GP2040-CE.

@LeeNX
Copy link

LeeNX commented Jun 15, 2023

Part 1 should be covered by PR bluekitchen/btstack#209.

Extending the HID for more buttons,axis and modes could be seen in https://github.com/lemmingDev/ESP32-BLE-Gamepad

and possibly ForceFeedback with https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary

@Fortinbra
Copy link
Contributor Author

Part 1 should be covered by PR bluekitchen/btstack#209.

Extending the HID for more buttons,axis and modes could be seen in https://github.com/lemmingDev/ESP32-BLE-Gamepad

and possibly ForceFeedback with https://github.com/YukMingLaw/ArduinoJoystickWithFFBLibrary

While this is great information to have. What I'm looking for, for the bounty, is someone to actually make a demonstration using our codebase as the example.

@dogtopus
Copy link
Contributor

dogtopus commented Jun 20, 2023

I didn't know Pico W also supports Bluetooth Classic (a crucial thing to have for emulating most console Bluetooth controllers) until now.

We might actually get somewhere pretty far with this bounty. GP2040 DIY handheld controller anyone?

@TheTrainGoes
Copy link
Contributor

@dogtopus yes please!

My dreams of a cord free Switch arcade stick are still within reach :)

@HoboDev
Copy link
Contributor

HoboDev commented Jun 22, 2023

Since the chip is connected via SPI... could this eventually be ported over to use ESP?

@dogtopus
Copy link
Contributor

dogtopus commented Jun 22, 2023

Since the chip is connected via SPI... could this eventually be ported over to use ESP?

In theory yes but we will eventually run into the issues with Bluekitchen's license agreement since it's not technically free software and from what I heard from them years ago, requires commercial licenses even if the firmware is open source but loaded officially to a board (open source or not) for sale.

RPi foundation licensed from them so the Bluekitchen stack can be used on Pico W free of charge but that only limits to Pico W.

(Also take this with a grain of salt since looks like their intention was to make it available for use with RP2040 and not just Pico W. It's better to formally ask them once we actually need to use the stack on non-Pico W boards.)

@hizzlekizzle
Copy link

Bluetooth support would also open the door for DIY receivers to connect bluetooth gamepads to S/NES or Wii extensions, right? That is, using the board as a receiver rather than a transmitter; similar to the SNES 'retro receiver' from 8bitdo?

@Fortinbra
Copy link
Contributor Author

Since the chip is connected via SPI... could this eventually be ported over to use ESP?

For GP2040-CE, we don't have any plans to support any platforms other than the RP2040. You're always welcome to fork, and do your own thing.

@Fortinbra
Copy link
Contributor Author

Bluetooth support would also open the door for DIY receivers to connect bluetooth gamepads to S/NES or Wii extensions, right? That is, using the board as a receiver rather than a transmitter; similar to the SNES 'retro receiver' from 8bitdo?

We need to get transmission working first.

@dogtopus
Copy link
Contributor

Since the chip is connected via SPI... could this eventually be ported over to use ESP?

For GP2040-CE, we don't have any plans to support any platforms other than the RP2040. You're always welcome to fork, and do your own thing.

I think they meant using ESP as an HCI, which I'm not sure if the license for the Bluekitchen stack in pico-sdk permits such use case.

@Fortinbra
Copy link
Contributor Author

Since the chip is connected via SPI... could this eventually be ported over to use ESP?

For GP2040-CE, we don't have any plans to support any platforms other than the RP2040. You're always welcome to fork, and do your own thing.

I think they meant using ESP as an HCI, which I'm not sure if the license for the Bluekitchen stack in pico-sdk permits such use case.

Oh, in that case, we're only utilizing what is available from the SDK, and we'll deviate after we have something working, if we have reason to.

@futaris
Copy link

futaris commented Jun 26, 2023

I know I said I'd have this working last month. I ended up ordering a couple more Pico Ws so I can implement this.

@sanjay900
Copy link

sanjay900 commented Jun 30, 2023

Bluetooth support would also open the door for DIY receivers to connect bluetooth gamepads to S/NES or Wii extensions, right? That is, using the board as a receiver rather than a transmitter; similar to the SNES 'retro receiver' from 8bitdo?

Just as a sidenote, having done this for a project of my own, there is a bug with the current Bluetooth driver that limits pico hid host polling pretty badly, raspberrypi/pico-sdk#1342

I was mostly focused on making pairs of transmitters and receivers as I was building wireless controllers with console support, but from what I understand that bug should affect receiving from hid in general

Mind you, I guess that's only a problem for non classic, and I suspect everything you'd be doing here would be bt classic anyways

@futaris
Copy link

futaris commented Jul 16, 2023

https://github.com/DavidPagels/retro-pico-switch

@aallan
Copy link

aallan commented Jul 18, 2023

(Also take this with a grain of salt since looks like raspberrypi/pico-sdk#1164 (comment) was to make it available for use with RP2040 and not just Pico W. It's better to formally ask them once we actually need to use the stack on non-Pico W boards.)

While the CWY43439 driver is licensed for commercial use for users of Pico W, or anyone else who builds their product around RP2040 and CYW43439, this is not the case for the BlueKitchen license.

In addition to the standard BTstack licensing terms, a supplemental license which covers commercial use of BTstack with Raspberry Pi Pico W or Raspberry Pi Pico WH has been provided. There is no exception for those using RP2040 on their own boards.

@dogtopus
Copy link
Contributor

@aallan Thanks for the clarification. I'm personally not a fan of this licensing model but I guess that's to be expected when using non-free libraries like bluekitchen stack.

@TheTrainGoes
Copy link
Contributor

This issue is going to be re-written to better reflect the goals of the project. I will keep it open until the new issue is posted.

@jars28
Copy link

jars28 commented Feb 21, 2024

https://github.com/DavidPagels/retro-pico-switch

Rough implementation of BlueTooth support with Switch connection is in this project.

@henrebotha
Copy link
Contributor

Rough implementation of BlueTooth support with Switch connection is in this project.

Unfortunately, it uses the Pico SDK, which I believe we can't use.

@Invictaz
Copy link

Bluetooth support would also open the door for DIY receivers to connect bluetooth gamepads to S/NES or Wii extensions, right? That is, using the board as a receiver rather than a transmitter; similar to the SNES 'retro receiver' from 8bitdo?

We already have that on ESP32 in Blueretro but there must be a reason that Blueretro doesn't get ported to Pico. Maybe because of limited flash storage or the lack of speed.

@dogtopus
Copy link
Contributor

Bluetooth support would also open the door for DIY receivers to connect bluetooth gamepads to S/NES or Wii extensions, right? That is, using the board as a receiver rather than a transmitter; similar to the SNES 'retro receiver' from 8bitdo?

We already have that on ESP32 in Blueretro but there must be a reason that Blueretro doesn't get ported to Pico. Maybe because of limited flash storage or the lack of speed.

It's the same reason why GP2040 is not ported to ESP32. Because it's heavily BSP-specific and effectively not portable without major time and effort spent to rewrite the code.

@jars28
Copy link

jars28 commented Feb 21, 2024

"Raspberry Pi Pico W customers benefit from a pre-paid commercial license for BTstack, allowing you to use Pico W as a component in your own products."

https://www.raspberrypi.com/news/new-functionality-bluetooth-for-pico-w/

@Fortinbra
Copy link
Contributor Author

Rough implementation of BlueTooth support with Switch connection is in this project.

Unfortunately, it uses the Pico SDK, which I believe we can't use.

The Pico Sdk is exactly what we're using, it's why we can't use other drivers for Bluetooth at the moment, only BlueStacks, since it's already part of the SDK.

@bsstephan
Copy link
Contributor

bsstephan commented Feb 21, 2024

Just adding citations here:

The driver is normally a non-commercial piece of software that has been licensed to RPi by BlueKitchen, and RPi has in turn licensed its free use only if you are creating a Pico-W or Pico-W derived product.

Both licenses lead to a scenario where the usage of BTstack would arguably (if not clearly) limit GP2040-CE to non-commercial applications and/or Pico W-only applications, so it's not an option for us at this time.

Addendum: but, of course, if someone does demonstrate all of this in a working state, maybe then it'd be worth trying to get our own license terms. A big if, to be clear, but just pointing out that the current reality doesn't shoot down the desire to experiment and get a PoC.

@sanjay900
Copy link

sanjay900 commented Feb 21, 2024

By the way, i did ask bluekitchen about this for one of my projects and got this response back:

At the moment, Raspberry Pi has license our stack for all of their Pico W boards. By this, the Pico W can be used in commercial products without a license from us.
If a RP2040 with some other Bluetooth Controller is used, this requires to sign a license agreement with us.
On the other hand, if you build your own board with a RP 2040, you still need a Bluetooth Controller to use Bluetooth. The Pico W uses a CYW43439 and modules with the are more expensive than a Pico W. If you order 1k of CYW43439 from Mouser/Digikey, you still pay 3.80 USD. If you buy RP2040 on a reel, that's 0.63 USD. This gets you already to about 4.50 USD and you still need a flash, oscillator, ... so, unless there's a good reason, it's easier and cheaper to just buy Pico Ws :)
If you want to be cheaper than the Pico W, I would suggest the ESP32 (BR/EDR/LE/Wifi) or the ESP32-C3 (LE/WIFI). You can either use the Bluedroid or NimBLE stack that is free to use, or ours with a license.
When you get closer to choosing a path, feel free to get back and discuss your licensing needs. We try to make our stack affordable to small startups/Makers with low volumes.

One thing i have seen some RP2040 based boards do is use other bluetooth modules.
I have seen these myself, but have not tried them so I don't know what libraries exist for them.

  • Arduino Nano RP2040 Connect which uses a Nina W102 uBlox module
  • Challenger RP2040 WiFi/BLE MkII which uses a ESP32-C3FN4. One thing about going this route is it would probably allow you to build upon BlueRetro, since you would just have to send across the ATT commands, as there is a ESP firmware out there that will just receive ATT commands over serial.

As for actually implementing bluetooth, XInput won't be possible since that needs USB due to how windows detects those devices, so you would have to implement something using standard HID, but that is easy enough and i have done that myself for my Pico W based firmware.

@TheTrainGoes
Copy link
Contributor

This is an odd line worth more investigation:

"If a RP2040 with some other Bluetooth Controller is used, this requires to sign a license agreement with us."

Mind reaching back out to see if the license is handled should we choose to use the same parts as the W?

Why would I do that if it costs more than the Pico W? Easy! I don't want to solder a bunch of them and I need more GPIO.

@sanjay900
Copy link

sanjay900 commented Feb 21, 2024

You would 100% have to license it with them if you use anything that isn't a PicoW, even if the parts are the same.

I think by that they mean if you wanted to say use btstack on one of the other various RP2040 boards with bluetooth, you would have to license that as well, as its only licensed for use with the PicoW specifically.

But i think if we were looking at other bluetooth modules i would assume they have some other bluetooth lib they can use.

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

No branches or pull requests