-
Notifications
You must be signed in to change notification settings - Fork 41
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
Support for Bluetooth #8
Comments
I have considered what it will require. I'll list my thoughts below for now:
|
No idea if this is accurate, but when switching to the BLE firmware, steam outputs this, after updating the nxp firmware before that:
They seem to be using the nxp chip as an swd programmer, which seems pretty brick resistant. |
Awesome. Thanks for that additional info @david-sawatzke. The CMSIS-DAP firmware seems really promising! Also, I'm aware I'm being a bit paranoid about bricking the nRF51822. Part of it is the "better safe than sorry" approach. Especially when it could ruin someone's hardware, which is no longer being produced :(. Also, I was fortunate enough to be on a podcast to talk about this project and got to talk to Jeff Keyzer (one of the designers for the SC) and he mentioned bricking the radio chip at least once (https://embedded.fm/episodes/304). So that adds a little to the concern ¯_(ツ)_/¯ |
I’m pretty sure you can reflash the nRF51822 over wired connection, since that’s what you do to enable BLE mode. |
@Boundarybreaker if you have any details on how the wired connection is reflashing the nRF51822 via Steam and how that might be leveraged or reproduced please let me know. Otherwise thanks for the tip regarding another path to dig into! |
I don't have any details, sadly. I just know that I didn't have the bluetooth dongle for one of my steam controllers, but was able to update it to BLE over wired connection. |
I've been reading through the nRF5 SDK docs; I found this little section on the nRF51's debugging interface in the nRF51 reference manual. It's not everything we need to know, but its a start. Also the same document has details on the nRF51822 UART, but that is pretty straight forward. We just need to upload a program that dumps outgoing data (from UART RX/ LPC11's TX) into either the nRF51's TX FIFO (RF comms) or BLE Valve is probably using a generic SoftDevice + customized GATT profile for utilizing the nRF51 as a BLE co-processor (many DIY-ers use the UART service in a GATT profile -- not whatever Valve did). It should be said that Bluetooth is different from BLE, and the nRF51822 doesn't support full-fledged Bluetooth. So maybe adjust the title of this issue... EDIT: I can confirm that the dongle is using an nRF24LU1P |
So I started reverse engineering the protocol a bit, the findings presented below are based on my reverse engineering efforts on version 57bf5c10 (which doesn't have bluetooth support). The USART protocol has a first "framing" layer where a packet starts with byte \0x02 and ends with byte \0x03. Byte \0x1f is used as an escaping character, such that within the packet, every time a 2, 3 or 1f is encountered, it is prefixed by a 1f and xor'd with 0x20. Code for doing the escaping (sorry, it's Rust, but I hope the idea is conveyed): fn usart_send_escaped_str(mut data: &[u8]) {
while let Some(pos) = data.iter().position(|&v| v == 0x02 || v == 0x03 || v == 0x1f) {
if pos != 0 {
usart_send_raw_str(&data[..pos]);
}
usart_send_raw_str(&[0x1f, data[pos] ^ 0x20]);
data = &data[pos + 1..];
}
if !data.is_empty() {
usart_send_raw_str(data);
}
} Once the framing layer is removed, we get a datagram-oriented protocol. The first byte of the datagram is usually a packet ID. This table is what I more-or-less understood happening. Note that this is all just an informed guess based on my RE efforts, and 1000% untested :D. I'll keep it updated when I find new stuff. Here are the packet IDs nRF->LPC:
Packet IDs LPC->nRF:
|
Here's some new info. It turns out there is an nRF firmware hidden within the That's a relatively small firmware, all things considered. Small enough that it seems doable to pick it apart relatively quickly to find its workings. I already identified the function that parses the protocol (and found some new LPC->nRF packets in the process) just by going through every function looking for a big if/else forest 😆. So I'll be focusing my effort on this cute little firmware, see what's to be found in there. |
@roblabla I must say I'm impressed with your progress! I recently ran across a multiple protocol support in the nRF5 SDK that theoretically allows both BLE and ESB protocols concurrently using Nordic's Timeslots API. Although this API isn't fully utilized in any existing opensource firmware that I"m aware of (looking into the Arduino support for the nRF52840 and CircuitPython firmware for various nRF chips) outside of scheduling events for BLE protocol usage via the Nordic softdevice (s130 seems to be the preferred softdevice version in the aforementioned firmwares). As far as reverse engineering purposes, the Timeslots API may not need special implementation as the Steam controller uses either ESB or BLE, but not at the same time. |
Any progress/update on this feature? I just tested my SC with my Switch using cable, and it works great! |
Hi, any progress on this? It’s a wonderful enhancement idea that I’d love to see working. |
Fantastic work! I have a SC that has been collecting dust until I stumbled on this project. Looking forward to bluetooth support! |
Not sure if there are plans for this already, but support for bluetooth would be awesome to see, especially for other with the switch lite. I know there is support for the BLE mode on the sc-controller project, that was rolled out after Valve rolled out the BLE mode.
The text was updated successfully, but these errors were encountered: