This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to printf to BLE Central (iPhone)

Unfortunately it is only ever explained here how printf is possible via UART. I wonder how printf is possible over BLE. I would like to send messages (strings) with numerical values to a logging app on the phone (and commands from the phone to the BLE device for execution, e.g. changing config data).

So how would I use printf to embed the numbers into strings and send them using the nus service? (without having to reinvent the wheel).

Parents
  • Hi Karl,

    thanks for your response!

    Yes, the nus service does not seem to be a problem. I have already tested that (with App_uart).

    But I would have to recode the printf function. How else should I embed numerical values, e.g. "speed(kmh)=%d" or "battery voltage=%d V" etc.?

    Where can I find documentation on the supported standard string functions? Is there a sprintf?

    Somehow I have to convert numbers to strings. (That's what I mean by "having to reinvent the wheel". That would be sad).

  • Hello,

    Stefan_B said:
    thanks for your response!

    No problem at all, I am happy to help!

    Stefan_B said:
    Is there a sprintf?

    Yes, this is the function you should use for the purpose you describe.
    Generate the string using sprintf and transfer it using the NUS service.

    Stefan_B said:
    Where can I find documentation on the supported standard string functions?

    You read about and see all the standard IO functions in the stdio.h file included in the Segger Embedded Studio files.

    Best regards,
    Karl

  • Yes, thank you!
    I overlooked that the sprintf function is present. Documentation can also be found on the Segger website: studio.segger.com/index.htm

Reply Children
No Data
Related