bri3d / esp32-isotp-ble-bridge

ESP32-IDF based BLE<->ISO-TP bridge targeting Macchina A0 hardware
Other
31 stars 28 forks source link

wifi + dhcp + http + websocket server #3

Closed brandonros closed 3 years ago

brandonros commented 3 years ago
brandonros commented 3 years ago
esptool.py v3.2-dev
Merged 25 ELF sections
Generated /Users/brandonros/Desktop/esp32-isotp-ble-bridge/build/isotp_ble_bridge.bin
[100%] Built target gen_project_binary
Error: app partition is too small for binary isotp_ble_bridge.bin size 0x111540:
  - Part 'factory' 0/0 @ 0x10000 size 0x100000 (overflow 0x11540)
make[2]: *** [esp-idf/esptool_py/CMakeFiles/app_check_size] Error 1
make[1]: *** [esp-idf/esptool_py/CMakeFiles/app_check_size.dir/all] Error 2
make: *** [all] Error 2
make failed with exit code 2

fixed with sdkconfig CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE

brandonros commented 3 years ago
I (1399) ISOTPtoBLE: CAN/TWAI Driver installed
I (1399) ISOTPtoBLE: CAN/TWAI Driver started
I (1409) ISOTPtoBLE: ISO-TP Handler started
I (16799) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1
I (16799) wifi:station: a4:4e:31:19:68:70 join, AID=1, bgn, 20
I (16809) wifi_server: station a4:4e:31:19:68:70 join, AID=1
I (16889) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
W (17229) wifi:<ba-add>idx:4 (ifx:1, a4:4e:31:19:68:70), tid:0, ssn:73, winSize:64
I (18889) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
I (22409) web_server: Handshake done, the new connection was opened
I (23419) web_server: frame len is 6
I (23419) web_server: Packet type: 2
I (23419) web_server: ws_pkt.payload[0000] = e0
I (23429) web_server: ws_pkt.payload[0001] = 07
I (23429) web_server: ws_pkt.payload[0002] = 00
I (23439) web_server: ws_pkt.payload[0003] = 00
I (23439) web_server: ws_pkt.payload[0004] = 3e
I (23449) web_server: ws_pkt.payload[0005] = 00
I (23449) web_server: adding websocket payload to send_message_queue
assertion "pxQueue" failed: file "IDF/components/freertos/queue.c", line 770, function: xQueueGenericSend

abort() was called at PC 0x4018844b on core 1
0x4018844b: __assert_func at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8)

Backtrace:0x400d3947:0x3ffe17b00x40090f69:0x3ffe17d0 0x40097892:0x3ffe17f0 0x4018844b:0x3ffe1860 0x40091a2e:0x3ffe1890 0x400db679:0x3ffe18d0 0x4014b67d:0x3ffe1920 0x40149bda:0x3ffe1940 0x40149022:0x3ffe1960 0x4019d7a7:0x3ffe1980 0x40149287:0x3ffe19a0 0x401492ef:0x3ffe19f0 0x400940e9:0x3ffe1a10 
0x400d3947: panic_abort at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_system/panic.c:391

0x40090f69: esp_system_abort at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_system/esp_system.c:128

0x40097892: abort at /Users/brandonros/Desktop/esp-idf-v4.4/components/newlib/abort.c:46

0x4018844b: __assert_func at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8)

0x40091a2e: xQueueGenericSend at /Users/brandonros/Desktop/esp-idf-v4.4/components/freertos/queue.c:770 (discriminator 1)

0x400db679: websocket_handler at /Users/brandonros/Desktop/esp32-isotp-ble-bridge/main/web_server.c:61 (discriminator 13)

0x4014b67d: httpd_req_new at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_parse.c:773

0x40149bda: httpd_sess_process at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_sess.c:412 (discriminator 15)

0x40149022: httpd_process_session at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_main.c:178 (discriminator 15)

0x4019d7a7: httpd_sess_enum at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_sess.c:50 (discriminator 1)

0x40149287: httpd_server at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_main.c:228

0x401492ef: httpd_thread at /Users/brandonros/Desktop/esp-idf-v4.4/components/esp_http_server/src/httpd_main.c:250 (discriminator 15)

0x400940e9: vPortTaskWrapper at /Users/brandonros/Desktop/esp-idf-v4.4/components/freertos/port/xtensa/port.c:168

device currently freaks out and reboots

steps to reproduce:

  1. build + flash + monitor
  2. connect to wifi with laptop
  3. open http://192.168.4.1 in web browser
  4. javascript will execute, open connect to websocket, send a websocket message

queue exception will happen and device will reboot

brandonros commented 3 years ago

@bri3d we're probably going to want to rework

static uint32_t send_identifier = SEND_IDENTIFIER;
static uint32_t receive_identifier = RECEIVE_IDENTIFIER;

not to be globally hardcoded. that would allow us to TX + RX ISO-TP PDUs to different arbitration IDs

bri3d commented 3 years ago

They’re already mutated and the isotp stack reinitialized by a BLE command. I think they’re just static by accident, that part should definitely be fixed :)

On Tue, Aug 17, 2021 at 7:51 PM Brandon Ros @.***> wrote:

@bri3d https://github.com/bri3d we're probably going to want to rework

static uint32_t send_identifier = SEND_IDENTIFIER; static uint32_t receive_identifier = RECEIVE_IDENTIFIER;

not to be globally hardcoded. that would allow us to TX + RX ISO-TP PDUs to different arbitration IDs

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/bri3d/esp32-isotp-ble-bridge/pull/3#issuecomment-900750672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABTO2LK6UVY7PTQCPVR3BLT5MG25ANCNFSM5CK5M4VA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

bri3d commented 3 years ago

Switched to the right account this time - This is so cool! Let me know when it is ready for a final review and check that the BLE stuff is still working.

brandonros commented 3 years ago

I would say let it rip final review wise. If you could handle the add tx_id + rx_id to the send_message_t, I think you might pull that off better than I would.

I'm preetttty confident nothing broke BLE wise, and I had it on bench talking to a Tactrix UDS emulator. It was 3E00 -> 7E00 correctly all day long, no crashes.

bri3d commented 3 years ago

I retested BLE and it works great. I am about to head out for vacation for a bit, so while I agree that adding tx/rx to the packets and supporting multiple devices will be valuable, for now I'll merge this so it doesn't sit in limbo forever. We can add tx/rx id support down the road.

Thank you so much, this is super cool! Looking forward to using the A0 more and more