You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/receive_and_send_single_packet.robot
+69-25Lines changed: 69 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -23,39 +23,43 @@ ${filter} g/${callsign}*
23
23
*** Test Cases ***
24
24
Simple Receive-and-Respond Test Case
25
25
[Documentation] Our 'master receiver' task
26
-
# The current Robot Framework does not support WHILE loops. This is a still a
26
+
# Robot Framework 4.x does not support WHILE loops. This is a still a
27
27
# finite loop but as our goal is only to receive a single message, this
28
-
# crude approach will do.
29
-
Wait Until Keyword Succeeds 50x 0sec Receive Packet From APRS-IS
28
+
# crude approach will do. Keep in mind that by default, the APRSLib is
29
+
# queried in "blocked" mode, meaning that we don't need any retries etc.
30
+
#
31
+
# The current setup will accept up to 10 messages, confirm them whereas
32
+
# necessary and send a pesonalized response. After processing these 10
33
+
# messages, the test will stop its execution
34
+
Wait Until Keyword Succeeds 10x 0sec Receive Packet From APRS-IS
30
35
31
36
*** Keywords ***
32
37
33
38
Receive packet from APRS-IS
34
39
[Documentation] VERY simplified ack-and-respond-to-message test case. Sends ack & msg to user, then terminates the test
40
+
41
+
# Get the packet from APRS-IS
35
42
Log Receive message from APRS-IS
36
43
${packet} = Receive APRS Packet
37
44
45
+
Log To Console Receive complete
46
+
47
+
# check what we have received so far
38
48
${format_string}= Get Format Value From APRS Packet ${packet}
39
-
Run Keyword If '${format_string}' != 'message' Fail msg=Packet format is not 'message'; start new loop
40
-
41
-
${from_string}= Get From Value From APRS Packet ${packet}
42
-
${adresse_string}= Get Adresse Value From APRS Packet ${packet}
43
-
${msgtext_string}= Get Message Text Value From APRS Packet ${packet}
44
49
45
-
# The msgno might not be present for unconfirmed messsages. A failure to extract the msgno
46
-
# simply triggers a new WUKS loop. After all, this is a VERY very simplified library demo.
47
-
#
48
-
# Therefore, I don't care about this case and simply expect to receive a message with a
49
-
# msgno present. Additionally, keep in mind that alphanumeric message number qualifiers
50
-
# are currently not parsed by the aprslib library.
51
-
${msgno_string}= Get Message Number Value From APRS Packet ${packet}
50
+
# and handle response/message formats
51
+
Run Keyword If '${format_string}' == 'response' Process APRS Response MYPACKET=${packet}
52
+
Run Keyword If '${format_string}' == 'message' Process APRS Message MYPACKET=${packet}
52
53
53
-
# If we have received an ack or a rej, we simply ignore the message and start anew
54
-
Run Keyword If '${msgtext_string}' == 'ack' Fail msg=Ignoring ack, start new loop
55
-
Run Keyword If '${msgtext_string}' == 'rej' Fail msg=Ignoring rej, start new loop
54
+
Log To Console And we're done
56
55
57
-
# show the user what we have received
58
-
Log To Console I have received '${msgtext_string}'
56
+
Send Acknowledgment
57
+
[Documentation] Send an acknowledgement in case the incoming message
58
+
[Arguments]${MYPACKET}
59
+
60
+
${from_string}= Get From Value From APRS Packet ${MYPACKET}
61
+
${adresse_string}= Get Adresse Value From APRS Packet ${MYPACKET}
62
+
${msgno_string}= Get Message Number Value From APRS Packet ${MYPACKET}
59
63
60
64
# Send the ack
61
65
# build the ack based on the incoming message number
@@ -65,21 +69,61 @@ Receive packet from APRS-IS
65
69
Send Packet to APRS-IS ${ackmsg}
66
70
67
71
# do not flood the APRS-IS network
68
-
Sleep 2sec
72
+
Log To Console Sleep 5 secs
73
+
Sleep 5sec
74
+
75
+
Process APRS Message
76
+
[Documentation] Process an APRS Message (format type: 'messsage')
77
+
[Arguments]${MYPACKET}
78
+
79
+
Log To Console Processing an APRS 'message' packet
80
+
81
+
# show the user what we have received
82
+
Log To Console I have received '${MYPACKET}' from APRS-IS
69
83
70
-
# Send the actual message
84
+
# Send an acknowledgment in case we have received a message containing a message number
85
+
${msgno_present}= Check If APRS Packet Contains Message Number ${MYPACKET}
86
+
Log To Console Message contains a message number: ${msgno_present}
87
+
88
+
Run Keyword If '${msgno_present}' == '${True}' Send Acknowledgment MYPACKET=${MYPACKET}
89
+
90
+
# Extract some fields from the original message
91
+
${from_string}= Get From Value From APRS Packet ${MYPACKET}
92
+
${adresse_string}= Get Adresse Value From APRS Packet ${MYPACKET}
93
+
94
+
# Send the response message
71
95
# Get a message number from the library
72
96
${mymsgno}= Get APRS MsgNo As Alphanumeric Value
97
+
73
98
# Increment the library's message number (not really necessary here as we only deal with one message)
74
99
Increment APRS MsgNo
100
+
75
101
# build the final string
76
102
${msg}= Format String {}>APRS::{:9}:{} {}{} ${adresse_string}${from_string} Hello ${from_string} , your Robot Overlords send greetings!
77
-
${msg}= Catenate SEPARATOR= ${msg} { ${mymsgno}
103
+
104
+
# our response will always contain a message number, even though the incoming message had none
105
+
# Remember that this is just a simple demo script
106
+
${msg}= Catenate SEPARATOR= ${msg} { ${mymsgno}
107
+
78
108
# and send the message to APRS-IS
79
-
Log To Console Sending actual message '${msg}'
109
+
Log To Console Sending response message '${msg}' to APRS-IS
80
110
Send Packet to APRS-IS ${msg}
81
111
82
-
Log To Console And we're done
112
+
# Since we do not intentionally fail this command sequence, we will automatically break free from the encapsulating WUKS
113
+
Log To Console Process APRS Message complete.
114
+
115
+
Process APRS Response
116
+
[Documentation] Process an APRS Response (format type: 'response'). Causes a desired fail (thus causing another WUKS loop) in case an ack/rej has been received
117
+
[Arguments]${MYPACKET}
118
+
119
+
# At this point, we already know that there is a response present. Normally, this can only be an ack or a rej
120
+
# but let's be sure about that and check the value
121
+
${response_string} Get Response Value from APRS Packet ${MYPACKET}
122
+
123
+
# If we have received an ack or a rej, we simply ignore the message and start anew
124
+
Run Keyword If '${response_string}' == 'ack' Fail msg=Ignoring ack, start new loop
125
+
Run Keyword If '${response_string}' == 'rej' Fail msg=Ignoring rej, start new loop
0 commit comments