Skip to content

Commit 204e2d9

Browse files
committed
test: notification with optional param, RPC methods returning nil (py None)
1 parent f102f25 commit 204e2d9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

examples/rpc_lite_client/rpc_lite_client.ino

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,19 @@ void loop() {
5555
client.notify("blink");
5656
Serial.println("Sent a blink notification");
5757

58+
int duration_ms = 100;
59+
client.notify("blink", duration_ms);
60+
Serial.println("Sent a 100ms blink notification");
61+
62+
MsgPack::object::nil_t out;
63+
ok = client.call("blink", out);
64+
Serial.print("Sent a blink RPC -> ");
65+
66+
if (ok) {
67+
Serial.println("Server returns without issues");
68+
} else {
69+
Serial.println("Server could not handle a notification as a call");
70+
}
71+
5872
delay(2000);
5973
}

extras/examples/serial_server_example.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ def divide(a, b):
1515
print("0 denominator: this will raise an exception")
1616
return a/b
1717

18-
def blink():
18+
def blink(duration=None):
1919
"""
20-
Used for notification
20+
Used for notification w/o parameter. Use also for testing calls returning None
2121
"""
22-
print("Blink maybe")
22+
if duration is not None:
23+
print(f"Blink for {duration}")
24+
else:
25+
print("Blink maybe")
2326

2427
def get_rand():
2528
"""

0 commit comments

Comments
 (0)