Skip to content

Commit c066da5

Browse files
authored
Merge pull request #529 from tyler-potyondy/mobisys-tutorial
Encrypted Sensor Data Tutorial - Minor Updates
2 parents a65b693 + dfcfd5f commit c066da5

File tree

2 files changed

+14
-1
lines changed
  • examples/tutorials/thread_tutorials/encrypted_sensor_data

2 files changed

+14
-1
lines changed

examples/tutorials/thread_tutorials/encrypted_sensor_data/02_openthread_final/main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string.h>
33

44
#include <assert.h>
5+
#include <ctype.h>
56

67
#include <libopenthread/platform/openthread-system.h>
78
#include <libopenthread/platform/plat.h>
@@ -62,6 +63,9 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[])
6263
// Print IPv6 address.
6364
print_ip_addr(instance);
6465

66+
// Initialize UDP interface.
67+
initUdp(instance);
68+
6569
// Start Thread network.
6670
while (otThreadSetEnabled(instance, true) != OT_ERROR_NONE) {
6771
printf("Failed to start Thread stack!\n");
@@ -182,7 +186,13 @@ void handleUdpRecv(void* aContext, otMessage* aMessage,
182186
buf[length] = '\n';
183187

184188
for (int i = 0; i < length; i++) {
185-
printf("%c", buf[i]);
189+
if (isprint((unsigned char)buf[i])) {
190+
printf("%c", buf[i]);
191+
} else {
192+
// In case the received char is not
193+
// printable, print '-'
194+
printf("-");
195+
}
186196
}
187197

188198
printf("\n");

examples/tutorials/thread_tutorials/encrypted_sensor_data/03_encrypted_data_final/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[])
6464
libtocksync_alarm_delay_ms(100);
6565
}
6666

67+
// initUDP
68+
initUdp(instance);
69+
6770
// Print IPv6 address.
6871
print_ip_addr(instance);
6972

0 commit comments

Comments
 (0)