Device drivers may define ASYNC procedures which handle messages sent by a device without a foregone request sent by the MNC. While the sat-nms device driver architecture is targeted to devices which only reply if requested to do this, ASYNC procedures provide a ways to handle unsolicited messages.
Basic concept
The concept behind ASYN procedures is a communication protocol which listens to the device all the time, reads all messages coming from the device. Each message is forwarded to the ASYNC procedures defined to check which procedure is in charge for this particular message.
The check ist done by comparing so called message tags to a reference value defined for the procedure. For JSON based protocols the message tag is one value in the JSON document.
There are a number of constraints you have to consider if a device sends messages without being requested to, specially if the device responds to requests and sends unsolicited messages as well:
ASYNC procedures will be executed in a driver, even if they are defined.ASYNC procedures.ASYNC procedure. As the ASYNC procedure runs asynchronously to the device driver thread, this may collide with commands sent from a PUT procedure.PROC ASYNC for JSON coded protocols
For JSON based protocols the definition of an asynchronous procedure starts with the keywords PROC ASYNC OBJECT, followed by an object path definition as used with the REST SET and REST PARSE statements. You find an extensive description about the JSON object model and object paths in chapter 2.2.6 REST I/O functions
The object path definition is terminated either by the keyword EXISTS or a = character and the reference value this JSON object gets compared to. The reference value may be a quoted string or the content of a driver variable. The procedure body gets executed if the JSON object defined by the object path contains a value equal to the reference value following the = character.
If the keyword EXISTS is used, the procedure gets executed if an object at the given location exists in the message, the value assigned to it doesn't care.
PROC ASYNC for SNMP protocols
With SNMP, PROC ASYNC TRAP may be used to process traps issued by a device. The syntax for this kind of procedure is as follows:
The keywords PROC ASYNC TRAP are followed by the SNMP trap number and a pattern text. The SNMP trap calls this procedure if it has been issued from the IP address set for this device, the SNMP trap number matches the number stated with this procedure and the text submitted by the trap receiver contains the pattern text.
The trap receiver in the M&C software processes every trap it receives and translates it to a multiline string which is passed to the procedure(s) which are in charge for this trap. The first line of this string contains the trap type, the IP address from which it was issued, the trap number and the specific number. If there are SNMP varbinds with this trap, for each varbind a line follows with the OID and the value if this varbind.
Example:
V1TRAP from 127.0.0.1 trapno=6 specific=99
1.3.6.1.4.1.53491.550.2.3.19.0=-76.33
1.3.6.1.4.1.53491.550.2.3.24.0=2
The varbinds may be interpreted with INPUT statements in the procedure body:
PROC ASYNC TRAP 6 "53491.550.2.3.19.0"
INPUT "53491.550.2.3.19.0=" TRM 10 inputLevel
INPUT "53491.550.2.3.24.0=" TRM 10 XLT tLock inputLock
The procedure above gets called for a trap (6) containing a varbind ending on "53491.550.2.3.19.0". The value of this varbind gets assigned to the driver variable inputLevel. The varbind ending on "53491.550.2.3.24.0" is assigned to 'inputLock' after translating it from the SNMP number encoding to the value expected in the driver. Using OID fragements starting with the deivce's enterprise ID is a reliable way to identify varbind OIDs in the trap text.
Remarks
PROC ASYNC TRAP procedures require the M&C server's trap receiver to setup properly. The file 'traprec.json' configures the properties of the trap receiver, the M&C user manual gives a conprehensive description of this configuration file.