How to read/write data via BLE in Mbed OS 6?

Not sure why you raise the question here. You do not seem to be using a Sparkfun board and Sparkfun is NOT using Mbed6.

Most people are using the Sparkfun V2.x library, which includes Mbed5. It is used in an Arduino IDE environment and ArduinoBLE is used for BLE communication. Mbed5 in V2.x has the complete MBED-Cordio BLE stack, but ArduinoBLE is maybe using 1% of that MBED Cordio stack. Only to connect to the Apollo3-BLE driver that is in the Sparkfun V2.x library.

If you want to program directly on MBED CORDIO BLE I think you are better off on

Maybe just a little help, out of interest I did create programs in the Arduino IDE environment which work directly with the Cordio BLE stack that is part of MBED in V2.x. (NOT using ArduinoBLE) The Cordio BLE stack is VERY complete and comprehensive, and I share your frustration about the lack of clarity in getting started and understanding the different calls and how it all works together. The different examples are standalone and do not provided examples of a working solution. I still know little about the Cordio BLE-stack, but I created a Client / server (or central/peripheral) programs. You can send data from a server/peripheral (e.g. from BME280) and receive that on a client / central, which can be another Sparkfun Apollo3 board or a BLEAK implementation on Ubuntu. The latter needs much more work. you can find this on