WinRT / C++ API ::Need to know when a BLE write has actually finished? RRS feed

  • Question

  • I'm writing to my lovely Noric UART BLE device with this code:

    auto status = co_await txc.WriteValueWithResultAsync(writer.DetachBuffer(), GattWriteOption::WriteWithoutResponse);

    I assumed the co_await would wait for the data to be written before returning. Nothing of the sort. The data gets held in some Windows dungeon and sent at some point in the future. I know this because I tested the write with a huge amount of data and the co_await returned whilst the data was being sent.

    I tried the WriteWithResponse option, but this appeared to hang the app.

    My application is a simple UART. I write, I read, I write, I read. Standard serial comms.

    Does anyone know how I should architect this kind of code?


    • Edited by Ev1lC Saturday, February 15, 2020 8:28 AM
    Friday, February 14, 2020 12:04 PM

All replies

  • GATT is BLE. A standard Bluetooth serial port profile is not BLE. What are you actually doing? Why use this obscure coroutine API rather than simple WriteFile etc.?

    -- pa

    Friday, February 14, 2020 10:24 PM
  • Please take the time to actually read the question.

    GATT is BLE.

    I know that.

    A standard Bluetooth serial port profile is not BLE.

    I also know that.

    What are you actually doing?

    Replying to your reply.

    Why use this obscure coroutine API rather than simple WriteFile etc.?

    The device is BLE as stated in the question, not SPP (RFCOMM). It uses the Nordic UART service to provide serial comms over BLE, as stated. I'm using the standard BLE API.

    Saturday, February 15, 2020 8:27 AM
  • Hello Ev1lC,

    This forum is for "Discuss Windows SDK Documentation, Samples and Tools." It is win32 C++ focused.

    For C++/WinRT related issue you can ask a question at Microsoft Q&A for more professional support. Thanks for your cooperation.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, February 17, 2020 2:51 AM
  • Since this question relates to BLE, the drivers forum is the best place for it. People who know BLE are there.

    -- pa

    Tuesday, February 18, 2020 12:30 AM