|
@@ -27,6 +27,16 @@
|
27
|
27
|
|
28
|
28
|
#include "tcp_comm.h"
|
29
|
29
|
|
|
30
|
+#ifdef DEBUG
|
|
31
|
+#include <stdio.h>
|
|
32
|
+#include "pico/stdio_usb.h"
|
|
33
|
+#define DBG_PRINTF_INIT() stdio_usb_init()
|
|
34
|
+#define DBG_PRINTF(...) printf(__VA_ARGS__)
|
|
35
|
+#else
|
|
36
|
+#define DBG_PRINTF_INIT() { }
|
|
37
|
+#define DBG_PRINTF(...) { }
|
|
38
|
+#endif
|
|
39
|
+
|
30
|
40
|
extern const char *wifi_ssid;
|
31
|
41
|
extern const char *wifi_pass;
|
32
|
42
|
critical_section_t critical_section;
|
|
@@ -511,23 +521,21 @@ struct comm_command reboot_cmd = {
|
511
|
521
|
|
512
|
522
|
int main()
|
513
|
523
|
{
|
514
|
|
- stdio_init_all();
|
515
|
|
-
|
516
|
|
- sleep_ms(1000);
|
|
524
|
+ DBG_PRINTF_INIT();
|
517
|
525
|
|
518
|
526
|
if (cyw43_arch_init()) {
|
519
|
|
- printf("failed to initialise\n");
|
|
527
|
+ DBG_PRINTF("failed to initialise\n");
|
520
|
528
|
return 1;
|
521
|
529
|
}
|
522
|
530
|
|
523
|
531
|
cyw43_arch_enable_sta_mode();
|
524
|
532
|
|
525
|
|
- printf("Connecting to WiFi...\n");
|
|
533
|
+ DBG_PRINTF("Connecting to WiFi...\n");
|
526
|
534
|
if (cyw43_arch_wifi_connect_timeout_ms(wifi_ssid, wifi_pass, CYW43_AUTH_WPA2_AES_PSK, 30000)) {
|
527
|
|
- printf("failed to connect.\n");
|
|
535
|
+ DBG_PRINTF("failed to connect.\n");
|
528
|
536
|
return 1;
|
529
|
537
|
} else {
|
530
|
|
- printf("Connected.\n");
|
|
538
|
+ DBG_PRINTF("Connected.\n");
|
531
|
539
|
}
|
532
|
540
|
|
533
|
541
|
critical_section_init(&critical_section);
|
|
@@ -550,7 +558,7 @@ int main()
|
550
|
558
|
for ( ; ; ) {
|
551
|
559
|
err_t err = tcp_comm_listen(tcp, TCP_PORT);
|
552
|
560
|
if (err != ERR_OK) {
|
553
|
|
- printf("Failed to start server: %d\n", err);
|
|
561
|
+ DBG_PRINTF("Failed to start server: %d\n", err);
|
554
|
562
|
sleep_ms(1000);
|
555
|
563
|
continue;
|
556
|
564
|
}
|