This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

iOS nRF Toolbox tx/rx characteristic?

Hi all, I'm using the nRF iOS Toolbox as a reference to design an app. Can someone please help me in terms of which swift code file I need to use to read and write data to the nrf51 ble devices? I have modified the uuids to match my device and can connect to the ble and write data using the PopUpController. But I have to send custom byte array data to the ble. So can someone please guide me through which part of code I need to use for writing/reading data from ble? I have done a few android apps using the same but swift is something that I'm not familiar with so if someone could help, that would be great. Thanks and Regards NP

Parents
  • Good evening nar0909 !

    If you head towards this link, you'll see the UART handling is done in the BluetoothManager class

    if you have any more questions just ask :), hope this helps

    Update: Added info to show actual usage for reading and writing

    To write, simply convert your string to bytes as we do here.

    Then use the method writeValue(...) on the target CBPeripheral, an example can be seen here

    When it comes to reading, you'll receive changes as notifications that will call the target CBPeripheral's didUpdateValue(...), this method can be found here

    You will receive the data as bytes and you are responsible to convert them back to a String, you can see how we do that here

    You may use the BluetoothManager class directly to do that, and access it from all the views that you require, but I would recommend to reimplement it by hand to get a really good understanding on how the whole service works. BluetoothManager is there only as an example reference and might be a bit too much or over complicate things depending on the solution you're working on. but feel free to use it as it is ofcourse.

  • Hi Mostafa, Thanks for your response. I was wondering which statement I should be using if I wanted to read and write to the nrf51822 BLE in each view controller scene? Can you please advice if I use the same NORBluetoothManager in all my view controller scenes. Can I do that? Thanks nar

Reply Children
No Data
Related