Open Groupix05 opened 2 weeks ago
It would be a good starting point for your project. Its main purpose is to fully pair an ESP32 to the Wii. There isn't much in the way of sending data packets to the Wii but once they are paired you can send whatever data you want (packets are well documented online elsewhere). You should be able to send the Wii anything a Wii remote can do. I wrote the code to be able to automate turning the Wii on and off. The power button is actually the trickiest thing to fake. I'll take a look at the code this weekend and see if I can offer some pointers. The hardest part will likely be setting up the ESP-IDF dev environment. It is always a PITA. So work on getting one of the samples to compile and run on an ESP32 and I'll help you with integrating my code. --nick
On Tue, Oct 15, 2024 at 10:46 AM Groupix05 @.***> wrote:
Hello, I would love to use your program to test things with my ESP32 Dev Module. But ESP IDF is not that easy, and there's no documentation or proper README on this project. I tried ESPIDF on VSCode and on CMD.
I searched everywhere on the web to connect my ESP32 on my wii and send Accelerometer data and other things. I found WiimoteEmulator, it works great but it's made for linux. And your project seems to be made for an ESP32.
So I wanted to ask if this project can make my ESP32 able to connect on my Wii, and if yes, if I can get any help on it.
I know it's been 3 years but it's very hard to found something for the Wii Bluetooth. There are a lot of projects for connecting to a Wiimote but that's not what I'm searching.
Thanks for your help !
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBT2E5PVV7LHOY5F5HLZ3VIHZAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4DSNBWGM4TQMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thank you so much!
I managed to build the code and flash it onto my ESP32. There were some errors in the code, but I managed to fix them (I think). It's maybe because of newer version of ESP-IDF. I used the code before "bthci" because I couldn't find it anywhere.
I'm more used to Arduino than ESP-IDF, so that's why this project is a bit complicated for me to set up.
Once on the ESP32, is it waiting for me to press the Sync Button on my Wii, or do I need to manually change the MAC address in the main code?
I will check the code more in-depth next week to understand how it works.
Thanks again!
I believe it is waiting for you to press the sync button on the Wii.
On Tue, Oct 15, 2024 at 11:54 AM Groupix05 @.***> wrote:
Thank you so much!
I managed to build the code and flash it onto my ESP32. There were some errors in the code, but I managed to fix them (I think). It's maybe because of newer version of ESP-IDF. I used the code before "bthci" because I couldn't find it anywhere.
I'm more used to Arduino than ESP-IDF, so that's why this project is a bit complicated for me to set up.
Once on the ESP32, is it waiting for me to press the Sync Button on my Wii, or do I need to manually change the MAC address in the main code?
I will check the code more in-depth next week to understand how it works.
Thanks again!
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2414777394, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBVWVIHWCN44JYV7VC3Z3VQHDAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJUG43TOMZZGQ . You are receiving this because you commented.Message ID: @.***>
Hello again, I managed to run the code on my ESP32, but nothing happens when it runs (and when I press the wii sync button) I have some errors with imports that I tried to fix : On the latest commit, I have: fatal error: bthci.h: No such file or directory So I tried with the commit just before this one, and I got this error : fatal error: esp_int_wdt.h: No such file or directory. I tried to change it with "esp_task_wdt.h" but I got a lot more errors in the code, like: error: unknown type name 'xQueueHandle'; error: unknown type name 'xSemaphoreHandle'; And I think it's when I tried to fix them I broke the code...
I don't know if I need to install additional components or not, I would like to know.
I'm using ESP-IDF 5.1.4 because I need Arduino as a component for other things, but for now, the component is not installed on the project. I'm using the ESP32 Dev module from Joy-it, the model is NodeMCU. I tried with ESP-IDF 5.3.1, on VSCode and on Konsole (I'm on linux). And I tried on Windows 11, VSCode and CMD.
I will check the code more in depth this week when I can, but those errors are not a piece of cake for me as I don't really know how ESPIDF works, and it's not my code. I will also try an older version of ESP-IDF, like 4.4.8 to see if this can fix some errors.
esp_int_wdt.h was likely deprecated in idf 5.x. do you have your code anywhere I can pull? I can try to get it to work.
On Sun, Oct 20, 2024 at 4:15 PM Groupix05 @.***> wrote:
Hello again, I managed to run the code on my ESP32, but nothing happens when it runs (and when I press the wii sync button) I have some errors with imports that I tried to fix : On the latest commit, I have: fatal error: bthci.h: No such file or directory So I tried with the commit just before this one, and I got this error : fatal error: esp_int_wdt.h: No such file or directory. I tried to change it with "esp_task_wdt.h" but I got a lot more errors in the code, like: error: unknown type name 'xQueueHandle'; error: unknown type name 'xSemaphoreHandle'; And I think it's when I tried to fix them I broke the code...
I don't know if I need to install additional components or not, I would like to know.
I'm using ESP-IDF 5.1.4 because I need Arduino as a component for other things, but for now, the component is not installed on the project. I'm using the ESP32 Dev module from Joy-it, the model is NodeMCU. I tried with ESP-IDF 5.3.1, on VSCode and on Konsole (I'm on linux). And I tried on Windows 11, VSCode and CMD.
I will check the code more in depth this week when I can, but those errors are not a piece of cake for me as I don't really know how ESPIDF works, and it's not my code. I will also try an older version of ESP-IDF, like 4.4.8 to see if this can fix some errors.
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2425281016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBS3KIB6J5IZ2ZC23GLZ4Q2QTAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRVGI4DCMBRGY . You are receiving this because you commented.Message ID: @.***>
It's just the same version as https://github.com/nickbits1024/esp32-wii-controller/tree/8033efe47708f14bd4b4b6939383aafe2173bc0b I cannot find bthci, so I use this version, I'm just trying to execute your project to see if I can make it work and make my esp32 able to connect to a real wii. I managed to run it and I think it's working, I see things in the idf monitor, but how can I clearly see things happening on my Wii, like I want my pin 2 (button) to act like a home button from a wiimote. (or On/Off) And is it normal it disconnect very rapidly ? EVT: (07) 04 05 04 00 81 00 22 disconnected handle 0x0081 status 0x0 reason 0x22 HCI_EVENT_DISCONNECTION_COMPLETE
I'm still learning C, and C++ but here it's not useful. https://github.com/Groupix05/esp32-wii-controller
I ran it with ESP-IDF 5.3.1 on Konsole.
Thanks again for this project and for taking the time to respond.
bthci is in my components repo. the controller project won't work without it nickbits1024/EspIdfComponents (github.com) https://github.com/nickbits1024/EspIdfComponents I'm out for most of this week so I'm not sure when I'll get to trying out your copy but hopefully when I get back. --nick
On Mon, Oct 21, 2024 at 5:36 AM Groupix05 @.***> wrote:
It's just the same version as https://github.com/nickbits1024/esp32-wii-controller/tree/8033efe47708f14bd4b4b6939383aafe2173bc0b I cannot find bthci, so I use this version, I'm just trying to execute your project to see if I can make it work and make my esp32 able to connect to a real wii. I managed to run it and I think it's working, I see things in the idf monitor, but how can I clearly see things happening on my Wii, like I want my pin 2 (button) to act like a home button from a wiimote. (or On/Off) And is it normal it disconnect very rapidly ? EVT: (07) 04 05 04 00 81 00 22 disconnected handle 0x0081 status 0x0 reason 0x22 HCI_EVENT_DISCONNECTION_COMPLETE
I'm still learning C, and C++ but here it's not useful. https://github.com/Groupix05/esp32-wii-controller
I ran it with ESP-IDF 5.3.1 on Konsole.
Thanks again for this project and for taking the time to respond.
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2426550064, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBXBBQDLRGVPFRDRVI3Z4TYNTAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRWGU2TAMBWGQ . You are receiving this because you commented.Message ID: @.***>
Thanks for the component, I can now run your code with it. https://github.com/Groupix05/esp32-wii-controller/tree/main
I still need help to understand how I can connect and send my custom data. When first loaded my esp says "remote is not paired", when I press the Wii's sync button I have "pairing complete!" and it disconnects, if I press the sync button again, I got l2cap config response con_handle 0x81 and a disconnect after a few seconds. I don't know how to get in "if (ret == ESP_OK && size == BDA_SIZE)" so I can execute your code to turn on and off the Wii after 30s.
There are some addresses in the main.c, but I don't know if I need to change something here or not, or if I need to put my Wii's MAC address or my ESP32 MAC address.
Since you have it paired, you can arbitrarily connect and open the l2cap channel it needs to fake wiimote commands. Then you can create/post the data packets with create_l2cap_packet and post_bt_packet. I have another repo which I consume my controller lib (nickbits1024/TvMux https://github.com/nickbits1024/TvMux). You might want to look at that to see how the on/off commands flow through the web api.
On Mon, Oct 28, 2024 at 2:16 PM Groupix05 @.***> wrote:
Thanks for the component, I can now run your code with it. https://github.com/Groupix05/esp32-wii-controller/tree/main
I still need help to understand how I can connect and send my custom data. When first loaded my esp says "remote is not paired", when I press the Wii's sync button I have "pairing complete!" and it disconnects, if I press again the sync button I got l2cap config response con_handle 0x81 and a disconnect after a few seconds. I don't know how to get in "if (ret == ESP_OK && size == BDA_SIZE)" so I can execute your code to turn on and off the Wii after 30s.
There are some address in the main.c, but I don't know if I need to change something here or not, and if I need to put my Wii's MAC address or my ESP32 MAC address.
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2442645779, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBSC7ODMXV5DRHAQGVLZ52LSDAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBSGY2DKNZXHE . You are receiving this because you commented.Message ID: @.***>
I don't know if it's correctly paired because "case HCI_EVENT_AUTHENTICATION_COMPLETE" is never called, wich call "nvs_set_blob(wii_controller.nvs_handle, WII_ADDR_BLOB_NAME, wii_addr, BDA_SIZE);" and I think with what's in the code makes my "esp_err_t ret = nvs_get_blob(wii_controller.nvs_handle, WII_ADDR_BLOB_NAME, wii_addr, &size);" to "ESP_OK" so I can turn off and on the wii with your code that you already put. (in fake_wii_remote() in fake_wii_remote.c) Sorry if this is misunderstood.
I saw there is a function continous_reporting_task(void* p) to continuously report to the Wii the data it needs. But first, I want to use your turn on and off in fake_wii_remote() with the code you put in comments.
I think this is the last part before I can send my data with continous_reporting_task function, I just need to fully pair my esp32.
I tried to call fake_wii_remote() after it says "pairing complete!", but I still got the "remote is not paired".
github.com/nickbits1024/TvMux is empty for me,
whoops I guess I never got around to posting it. It's there now.
On Tue, Oct 29, 2024 at 2:49 PM Groupix05 @.***> wrote:
I don't know if it's correctly paired because "case HCI_EVENT_AUTHENTICATION_COMPLETE" is never called, wich call "nvs_set_blob(wii_controller.nvs_handle, WII_ADDR_BLOB_NAME, wii_addr, BDA_SIZE);" and I think with what's in the code makes my "esp_err_t ret = nvs_get_blob(wii_controller.nvs_handle, WII_ADDR_BLOB_NAME, wii_addr, &size);" to "ESP_OK" so I can turn off and on the wii with your code that you already put. (in fake_wii_remote() in fake_wii_remote.c) Sorry if this is misunderstood.
I saw there is a function continous_reporting_task(void* p) to continuously report to the Wii the data it needs. But first, I want to use your turn on and off in fake_wii_remote() with the code you put in comments.
I think this is the last part before I can send my data with continous_reporting_task function, I just need to fully pair my esp32.
I tried to call fake_wii_remote() after it says "pairing complete!", but I still got the "remote is not paired".
github.com/nickbits1024/TvMux is empty for me,
Screenshot_20241029_222832.png (view on web) https://github.com/user-attachments/assets/f9ecfa88-9d9b-4b34-8f8b-5d002e798392
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2445393927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBVUISJPZNH4DW6Y4RDZ577HNAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBVGM4TGOJSG4 . You are receiving this because you commented.Message ID: @.***>
Arg, this one is maybe too complicated for me to build. Is this necessary ?
If on and off are too hard, I will not do it. I just want to send a "home", when I receive 0x30 or 0x33 or something else, like in the continuous_reporting_task. I don't want something too complicated, just pair and send data to the Wii and that's it. Like to see, I want to send "home", I know it's 00 80 for home when I replace BB BB with the help of Wiibrew documentation. Once I can send this, I can send whatever I want...
I think I can pair correctly, but I don't know how to do the authentication, or maybe it's because of the mac address. I don't know. Do I need to alter something in the main.c ? Like I see addr[6], but I don't know if I am supposed to put a real wiimote mac address, or my esp32's mac address or my Wii's mac address.
If I make a loop, I can't connect any wiimote on the Wii, so it's doing something, but it's on this part I need help to understand how I can send data to the Wii. Thanks again for the help.
I wouldn't build it,, just look at the wii_* functions. If it is paired, you don't need to do anything for authentication. Just connect and open the data channels. You don't need a real wiimote mac, whatever was in there will work. I think if you connect and start a thread (maybe pumping a queue with your messagers) and use create_l2cap_packet / post_bt_packet it should work. You'll need to send the exact format of the complete l2cap payloads for the wiimote. --nick
On Tue, Oct 29, 2024 at 5:34 PM Groupix05 @.***> wrote:
Arg, this one is maybe too complicated for me to build. Is this necessary ?
If on and off are too hard, I will not do it. I just want to send a "home", when I receive 0x30 or 0x33 or something else, like in the continuous_reporting_task. I don't want something too complicated, just pair and send data to the Wii and that's it. Like to see, I want to send "home", I know it's 00 80 for home when I replace BB BB with the help of Wiibrew documentation. Once I can send this, I can send whatever I want...
I think I can pair correctly, but I don't know how to do the authentication, or maybe it's because of the mac address. I don't know. Do I need to alter something in the main.c ? Like I see addr[6], but I don't know if I am supposed to put a real wiimote mac address, or my esp32's mac address or my Wii's mac address.
If I make a loop, I can't connect any wiimote on the Wii, so it's doing something, but it's on this part I need help to understand how I can send data to the Wii. Thanks again for the help.
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2445571497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBWMJVO27EO7OTAWGC3Z6ASRHAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBVGU3TCNBZG4 . You are receiving this because you commented.Message ID: @.***>
Ok, I made a test branch in my fork to test things.
I managed to send home button to the Wii multiple time, but after 3-5s it stops. I've just started continous_reporting_task and removed the send_disconnect after the pairing is completed. I have some logs, I don't know if you have time to tell me what's wrong in this log, but this is the last step before sending my custom data with continous_reporting_task, I think.
I've also managed to turn off the Wii. Didn't try yet the turn on, but I think it should work.
I looked a bit in TvMux, but it seems to be the same functions as in fake_wii_remote.c, but a bit modified.
Sorry to bother you, but I really want to send custom data with my ESP32.
First, you should only ever need to pair once. It is permanent. It saves the link key to the flash and responses with the key during the hcp_link_key_request event. So you can just connect and open your l2cap channels. I have one idea of what could be going wrong. I noticed a lot of "unhandled HID output report" messages in your log. The Wii might be waiting for a response to and disconnecting after a certain amount of time. So I'd start by responding to all the messages. --nick
On Wed, Oct 30, 2024 at 4:54 PM Groupix05 @.***> wrote:
Ok, I made a test branch https://github.com/Groupix05/esp32-wii-controller/tree/testing in my fork to test things.
I managed to send home button to the Wii multiple time, but after 3-5s it stops. I've just started continous_reporting_task and removed the send_disconnect after the pairing is completed. I have some logs https://github.com/Groupix05/esp32-wii-controller/blob/testing/logs.txt, I don't know if you have time to tell me what's wrong in this log, but this is the last step before sending my custom data with continous_reporting_task, I think.
I've also managed to turn off the Wii. Didn't try yet the turn on, but I think it should work.
I looked a bit in TvMux, but it seems to be the same functions as in fake_wii_remote.c, but a bit modified.
Sorry to bother you, but I really want to send custom data with my ESP32.
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2448692008, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBUWLNDNWJIGRUYD2ELZ6FWSFAVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBYGY4TEMBQHA . You are receiving this because you commented.Message ID: @.***>
It's not permanent on my code because nvs_set_blob is never called when pairing or after the pairing. To call this I need to call handle_fake_wii_remote_authentication_complete(HCI_AUTHENTICATION_COMPLETE_EVENT_PACKET* packet), but this function is never called because in fake_wii_remote_packet_handler, event_packet->event_code is never HCI_EVENT_AUTHENTICATION_COMPLETE, I don't know how I can get it in HCI_EVENT_AUTHENTICATION_COMPLETE. That's why I was talking about Authentication.
I've also noticed about all the "unhandled HID output report" messages, I will try to fix them to see if I can make my esp32 always connected. (just wondering, your code doesn't have any code for WII_LED_REPORT, and WII_IR_REPORT and other unhandled HID output report ? I will try to do it myself.)
I didn't do anything for the led or IR reports because I didn't need them. I was solely looking to turn the wii on and off. I no joke spent about 100 hours figuring that out lol For the pairing, it should save in HCI_EVENT_LINK_KEY_NOTIFICATION not HCI_EVENT_AUTHENTICATION_COMPLETE. Your log does say "pairing complete" so it should be working. HCI_EVENT_AUTHENTICATION_COMPLETE isn't necessary. It was leftover from when I was figuring everything out.
On Thu, Oct 31, 2024 at 11:16 AM Groupix05 @.***> wrote:
It's not permanent on my code because nvs_set_blob is never called when pairing or after the pairing. To call this I need to call handle_fake_wii_remote_authentication_complete(HCI_AUTHENTICATION_COMPLETE_EVENT_PACKET* packet), but this function is never called because in fake_wii_remote_packet_handler, event_packet->event_code is never HCI_EVENT_AUTHENTICATION_COMPLETE, I don't know how I can get it in HCI_EVENT_AUTHENTICATION_COMPLETE. That's why I was talking about Authentication.
I've also noticed about all the "unhandled HID output report" messages, I will try to fix them to see if I can make my esp32 always connected. (just wondering, your code doesn't have any code for WII_LED_REPORT, and WII_IR_REPORT and other unhandled HID output report ? I will try to do it myself.)
— Reply to this email directly, view it on GitHub https://github.com/nickbits1024/esp32-wii-controller/issues/1#issuecomment-2450540695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5DGBXUOIRDJ4KDEZ6ID5LZ6JXY3AVCNFSM6AAAAABP7V2OB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJQGU2DANRZGU . You are receiving this because you commented.Message ID: @.***>
Thanks, I placed nvs_set_blob after the pairing complete and now when I turn on my esp32, it can directly connect to my Wii.
I tried your little code to turn on and off after 30s, but I think I have the same problem as continuous_reporting_task.
I don't think it's because of those "unhandled HID output report" I can't send any more data. I found out in my first log, there is a disconnection request near the start of the communication: line 165 : EVT: (11) 02 81 20 0c 00 08 00 01 00 06 03 04 00 40 00 46 00 l2cap disconnect request con_handle 0x81 id 0x3 dest_cid 0x40 source_cid 0x46 I think that can stop the communication after a bit. With powering off and on (the newer code on my testing branch), I can power it on if it's off, but I can't do the second command, turning off. If I reverse the commands, I can power it off, but I can't power it on. I think I can't reconnect correctly after the disconnection. (I tried with 1, 10 and 30s delay). This time there is no L2cap disconnection request, just a simple HCI_DISCONNECT. Here's my second log.
Or it's maybe because of too many HCI_CREATE_CONNECTION request, the wii will ignore after too many ? The second log is very short, and I don't really understand why I can't do the second command ...
Sorry again for all of those questions. I was searching a project to connect my esp32 to my wii and finally found your work, and see that I'm so close to do what I want...
Hello, I would love to use your program to test things with my ESP32 Dev Module. But ESP IDF is not that easy, and there's no documentation or proper README on this project. I tried ESPIDF on VSCode and on CMD.
I searched everywhere on the web to connect my ESP32 on my wii and send Accelerometer data and other things. I found WiimoteEmulator, it works great but it's made for linux. And your project seems to be made for an ESP32.
So I wanted to ask if this project can make my ESP32 able to connect on my Wii, and if yes, if I can get any help on it.
I know it's been 3 years but it's very hard to found something for the Wii Bluetooth. There are a lot of projects for connecting to a Wiimote but that's not what I'm searching.
Thanks for your help !