iOS NRF mesh connection handling on app side

Hi,

I am developing a react native app with the iOS and Android NRF mesh lbrary. In this app I am handling connection, data receiving on characteristic and sending on write characteristic (after segmenting based on mtu).

For Android this was straight forward as it gave callbacks: getMtu(), onPduCreated(byte[] pdu), handleNotifications(byte[] pdu) and handleWriteCallbacks(byte[] pdu). This gave simple byte data to send and receive on the app side

In iOS example app though it was using GattBearer where writing to the characteristic happened inside the library itself and it required CBPeripheral object to work with.

How do I setup the iOS library to make it work similar to android. i.e. let it handle only the data and assembling the pdu. Actual BLE interaction letting the app handle it.

This is important since the ble setup is common code in the react native app and would prefer to keep it that way.

Parents Reply
  • The manager gives the whole packet to the transmitter and expects a whole packet when it is received. You have to do the segmentation and slit to MTU-size packets on your own, if you're using a custom bearer. You may use ProxyProtocolHandler which can split the data for you, or implement the same functionality on your own.

    The PDU type is what you get from the manager (link) when sending data. You have to pass it to the ProxyProtocolHandler here. The same applies when you receive a packet - you get it from the handler and have to pass it to the manager.

    When you're doing a provisioning, you have to pass the ProvisioningBearer to provision method. In this bearer object you need to implement sending and receiving data like for normal bearer. This time it is not split into a transmitter and a callback. You still can use ProxyProvisioningHandler class to help you with SAR.

Children
  • Hi Aleksander,

    Looks like ProxyProtocolHandler is exactly what I am looking for. Thanks a lot for that.

    Also when starting provisioning it expects a provisioning bearer. Does it not use the MeshNetworkManager.transmitter in that case? 

    I am guessing based on your response the answer to above is it does not use.

    Is it possible to have a common bearer object that can be assigned to both MeshNetworkManager.transmitter and provision function. Bearer seems to be extension of Transmitter so I think that should be possible

    I'm trying to bring the interface as close to android as possible

  • Yes, it is possible, of course. The difference is, that when you're using GATT Proxy, the mesh data are sent over Mesh Proxy Service, while provisioning over Mesh Provisioning Service. But if you'll manage to implement it in a single class, that's ok.

    Also, you may also set the MeshNetworkManager as your bearer's dataDelegate (so you'll no have to call `bearerDidReceiveData` method directly) and your bearer as manager's transmitter.

  • We're working on mesh library in Kotlin with API much closer to the iOS version. But it most probably wont be ready this year, and will not be backwards compatible with the current Java version.

  • Thanks a lot Aleksander.

    I may contact again if I run into any issues

  • Related