IOS-nRF-Mesh-Library
IOS-nRF-Mesh-Library copied to clipboard
Send message await forever
Where do you suspect the issue?
Issue in mesh library, e.g. packets being dropped
Version
4.1.0 (latest)
Describe the issue
_ = try? await globalMeshNetworkManager?.send(meshMessage, to: MeshAddress(sendMessageTask.address), using: applicationKey)
I send an AcknowledgedMeshMessage
but get bearerDidClose
error.
this else isn't handled, so the library awaits forever. What should I do?
Thank you for reporting the issue. I'll look into it and come back to you.
For Acknowledged messages there's a timer on Access Layer that should try to retransmit the message and time out eventually.
OK. I see where the issue may occur.
AccessLayer sets the repeat & timeout timer only for acknowledge messages sent to a Unicast Address: https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library/blob/293210d4827ab865462f70aa32daa9493cb13fbd/nRFMeshProvision/Layers/Access%20Layer/AccessLayer.swift#L239-L244
That means, that acknowledged messages sent to a Group Address (or Virtual Address) don't get that timer set. Such messages may be sent to 0+ nodes and the transmitter can receive 0+ responses. In that case, it is the underlying layer that should notify the network manager, just like for unacknowledged messages.
However, as you pointed out, when the Acknowledged Mesh Message is unsegmented, like ConfigOnOffSet
, and sending the message fails, the network manager is never notified:
https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library/blob/293210d4827ab865462f70aa32daa9493cb13fbd/nRFMeshProvision/Layers/Lower%20Transport%20Layer/LowerTransportLayer.swift#L257-L260
I'll prepare a fix.
Btw, for multicast addresses it is recommended not to use Acknowledged messages, but their Unacknowledged counterparts. This significantly decreases the traffic in the network.
Hmm... I did some more digging and seems like the Network Layer doesn't throw bearerDidClose
when the message is sent to a group address, as such message may be handled internally:
https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library/blob/293210d4827ab865462f70aa32daa9493cb13fbd/nRFMeshProvision/Layers/Network%20Layer/NetworkLayer.swift#L156-L167
This is the shouldLoopback
method:
https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library/blob/293210d4827ab865462f70aa32daa9493cb13fbd/nRFMeshProvision/Layers/Network%20Layer/NetworkLayer.swift#L444-L450
As you're getting that error, that means, that you're sending the message to a Unicast Address. In that case, the network manager should wait until the response is received from the target, which happens on Access Layer. I'll leave #600 open, but don't think it's required.
Could you say what message are you trying to send exactly, what are your network parameters (default?) and what is the destination address of the message?
Thank you for your help. I just send some GenericOnOffSet to a Unicast Address when not connected.In this case, a timeout will not be thrown?
There will be a timeout. The timeout is set using: https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library/blob/293210d4827ab865462f70aa32daa9493cb13fbd/nRFMeshProvision/Layers/NetworkParameters.swift#L219-L230 Documentatuion
I found failedToSendMessage is no callback. Because Address change to MeshMessage. After fix it. I can handle the timeout here.
Can I handle deliveryCallbacks here?