That is cool. I remembered something. Your board is not contain standard CAN controller but FDCAN controller, which was first time implemented into can_api with STM32H7. So maybe there can be an issue for extended id.
- FDCAN Support for STM32G474 Nucleo - Mbed OS - Arm Mbed OS support forum
- Feature stm32g4 can support by m-ecry · Pull Request #13565 · ARMmbed/mbed-os (github.com)
However, from my point of view, if you are trying to solve a problem, it would be good to try that with the Mbed CAN api example. It could be used on one board with CAN-bus loop back between both CAN controllers. If that will work, then you can use it again on two different boards and so on.
BR, Jan