View Full Version : More RPC Completion Status
rbelli1
05-12-2011, 06:55 PM
I would like a way to determine if an RPC has completed due to another node's ACK or a timeout. Right now HOOK_RPC_SENT only indicates that the radio has sent the bits out on the air.
BoB
Jheath
05-14-2011, 09:33 PM
The best way to ensure an RPC was received by a remote node is to issue a return RPC as an acknowledgement (Application Layer Ack).
SNAP has a built-in function called rpcSourceAddr() that will give the SNAP address of the node that called that particular RPC.
Ex.
Node A:def func1():
global waitingForResp
rpc(nodeBAddr, "doSomethingFun")
waitingForResp = True
def ack():
waitingForResp = False
# And whatever else you would like to do now
Node B:def doSomethingFun():
rpc(rpcSourceAddr(), "ack")
#now something fun
Another option is to use the callback() or callout() built-ins. These allow you to invoke functions on remote nodes as well as a subsequent action.
Here is an example from the SNAP Reference manual for callback:
Ex. node A could invoke the following on node B:callback('showResult', 'readAdc', 0)
Node “B” would invoke readAdc(0), and then remotely invoke showResult(the-actual-ADC-reading-goes-here) on node A.
The callback() function is most commonly used with the rpc() function. For example:rpc(nodeB, 'callback', 'showResult', 'readAdc', 0)
Basically callback() allows you to ask one node to do something, and then tell you how it turned out.
Callout() is a similar function that allows on node to request an action on another node and then report this information to a third node.
rbelli1
05-15-2011, 01:07 PM
I do use application level acknowledgement. However, my system is designed with infrastructure. If a "repeater" node is present but the message is lost to the "master" node that is totally different than if nobody is there at all.
Right now I just try to talk to the master and sleep if there is no reply. I could sleep sooner if all of my rpc calls timed out because *NO* modes are available instead of repeaters and no master.
My system has some battery powered "slave" nodes that do not participate in hopping and some that are line or generator powered that will do hopping. Eventually I need to detect that there is a powered slave and no master due to the possibility that the powered node might have GSM or satellite capability.
There could be another parameter to the rpc call that told snappy to wait until the rpc was finished sending before calling the hook. Then another parameter to the HOOK_RPC_SENT event that tells why the node stopped trying to send (ex. ACK, timeout, radio shutdown). Most instances this information is not useful but the information is available somewhere in the sytem so why not make it available to the user?
BoB
Jheath
05-15-2011, 01:57 PM
Gotcha,
We will explore adding something like a separate HOOK that indicates the RPC was sent and acknowledged.
MoisesEsc
05-26-2011, 12:57 AM
It would be great to have rpc() return delivery status or ack.
Jheath
05-27-2011, 06:13 PM
Correct. As it stands today (2.4.x) the RPC() function does give a return value of True/False indicating whether the RPC was enqueued to be sent.
Today, you can ensure remote end reception by adding an application layer acknowledgement. See above for a code snippet.
We will explore adding something like a separate HOOK that indicates the RPC was sent and acknowledged.
vBulletin® v3.8.0, Copyright ©2000-2012, Jelsoft Enterprises Ltd.