Open Mendrzec opened 2 years ago
p_buf
is ~never freed and~ referenced even if its is nullptr: https://github.com/aed3/PS4-esp32/blob/03f82acd0986de949a00f52421221d709c3c3413/src/ps4_l2cap.c#L102
fyi @JavadRah
Hi @JavadRah, I tried to reproduce the issue using following script called every 50ms in a loop but had no luck so far:
if (PS4.Down()) {
PS4.setLed(123, 23, 45);
} else {
PS4.setLed(0, 80, 90);
}
PS4.sendToController();
It works perfectly for me.
Could you apply following change to https://github.com/aed3/PS4-esp32/blob/03f82acd0986de949a00f52421221d709c3c3413/src/ps4_l2cap.c#L104 and try again:
BT_HDR *p_buf = NULL; //here
p_buf = (BT_HDR *)osi_malloc(BT_DEFAULT_BUFFER_SIZE);
if (!p_buf) {
ESP_LOGE(PS4_TAG, "[%s] allocating buffer for sending the command failed", __func__);
return; //here
}
Hi @Mendrzec ! I wanted to use an I2C module with this library and found some strange bugs. When I turn on the controller and it pairs, I2c can no longer be used and it works in pieces and ESP32 hangs. Otherwise everything works fine when the Controller is not connected.
Hi @JavadRah, I tried to reproduce the issue using following script called every 50ms in a loop but had no luck so far:
if (PS4.Down()) { PS4.setLed(123, 23, 45); } else { PS4.setLed(0, 80, 90); } PS4.sendToController();
It works perfectly for me.
- Could you apply following change to https://github.com/aed3/PS4-esp32/blob/03f82acd0986de949a00f52421221d709c3c3413/src/ps4_l2cap.c#L104 and try again:
BT_HDR *p_buf = NULL; //here p_buf = (BT_HDR *)osi_malloc(BT_DEFAULT_BUFFER_SIZE); if (!p_buf) { ESP_LOGE(PS4_TAG, "[%s] allocating buffer for sending the command failed", __func__); return; //here }
- Could you share your source code?
Hi, sorry for the delay in reply. I used the PS4SendData example with your suggested edit, here is the log:
I (681) PS4_L2CAP: [ps4_l2cap_init_service] Service PS4-HIDC Initialized
I (681) PS4_L2CAP: [ps4_l2cap_init_service] Service PS4-HIDI Initialized
RI (1677) PS4_SPP: ESP_SPP_INIT_EVT
eady.
I (66299) PS4_L2CAP: [ps4_l2cap_connect_ind_cback] bd_addr: ⸮⸮⸮b⸮
l2cap_cid: 0x41
psm: 17
id: 4
I (66319) PS4_L2CAP: [ps4_l2cap_config_ind_cback] l2cap_cid: 0x41
p_cfg->result: 0
p_cfg->mtu_present: 1
p_cfg->mtu: 672
I (66321) PS4_L2CAP: [ps4_l2cap_config_cfm_cback] l2cap_cid: 0x41
p_cfg->result: 0
I (66329) PS4_L2CAP: [ps4_l2cap_connect_ind_cback] bd_addr: ⸮⸮⸮b⸮
l2cap_cid: 0x40
psm: 19
id: 6
I (66346) PS4_L2CAP: [ps4_l2cap_config_ind_cback] l2cap_cid: 0x40
p_cfg->result: 0
p_cfg->mtu_present: 1
p_cfg->mtu: 672
I (66350) PS4_L2CAP: [ps4_l2cap_config_cfm_cback] l2cap_cid: 0x40
p_cfg->result: 0
I (66357) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66482) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66483) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66493) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66503) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66513) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66523) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66533) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66543) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66553) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66563) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66573) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66583) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66593) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66603) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66613) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66623) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66633) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66643) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66653) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66663) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66673) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66683) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66693) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66703) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66713) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66723) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66733) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
E (66743) PS4_L2CAP: [ps4_l2cap_send_hid] allocating buffer for sending the command failed
I (66753) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66763) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66773) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66783) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66793) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66803) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
I (66813) PS4_L2CAP: [ps4_l2cap_congest_cback] l2cap_cid: 0x41
congested: 1
W (66813) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: congested
E (66825) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
E (66835) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
E (66845) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
E (66855) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
E (66865) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
E (66875) PS4_L2CAP: [ps4_l2cap_send_hid] sending command: failed
@Mendrzec today I checked the SendData example and I figure out that the send data function doesn't work. So I put the complete output for you:
anyway, I was trying to write another program, so I just send setLED command, I receive just:
PS4_L2CAP: [ps4_l2cap_send_hid] sending command: success
nothing else happened.Originally posted by @JavadRah in https://github.com/aed3/PS4-esp32/pull/25#issuecomment-933639843