INF2004-Project v0.1
 
Loading...
Searching...
No Matches
wifi.h
Go to the documentation of this file.
1
18#ifndef WIFI_H // Include guard.
19#define WIFI_H
20
21#include <stdio.h>
22#include "lwip/pbuf.h"
23#include "lwip/tcp.h"
24
32#define WIFI_BUFFER_SIZE 2048
34#define WIFI_TCP_PORT 4242
36#define WIFI_POLL_TIME_S 20
38#define WIFI_MAX_MESSAGE_LENGTH 1024 // End of wifi_constants group.
41
42#ifndef NDEBUG
48#define DEBUG_PRINT(...) printf(__VA_ARGS__)
49#else
50#define DEBUG_PRINT(...)
51#endif
52
61typedef struct wifi_tcp_server
62{
63 struct tcp_pcb *p_server_pcb;
64 struct tcp_pcb *p_client_pcb;
72
73// Function prototypes
74// ----------------------------------------------------------------------------
75//
76
78void wifi_tcp_server_begin(void);
79err_t wifi_tcp_server_send_data(void *p_arg, struct tcp_pcb *p_tpcb);
80err_t wifi_tcp_server_recv(void *p_arg,
81 __unused struct tcp_pcb *p_tpcb,
82 struct pbuf *p_buf,
83 __unused err_t err);
85
86#endif // WIFI_H
87
88// End of file driver/wifi/wifi.h.
#define WIFI_BUFFER_SIZE
Buffer size for messages sent out via wifi.
Definition: wifi.h:32
Struct representing a TCP server connection.
Definition: wifi.h:62
int run_count
Counter for tracking the state of the connection.
Definition: wifi.h:70
int sent_len
Length of sent data.
Definition: wifi.h:68
int recv_len
Length of received data.
Definition: wifi.h:69
bool is_complete
Flag indicating whether the connection is complete.
Definition: wifi.h:65
uint8_t buffer_recv[WIFI_BUFFER_SIZE]
Buffer for received data.
Definition: wifi.h:67
uint8_t buffer_sent[WIFI_BUFFER_SIZE]
Buffer for sent data.
Definition: wifi.h:66
struct tcp_pcb * p_server_pcb
Pointer to the server PCB.
Definition: wifi.h:63
struct tcp_pcb * p_client_pcb
Pointer to the client PCB.
Definition: wifi.h:64
err_t wifi_tcp_server_send_data(void *p_arg, struct tcp_pcb *p_tpcb)
This function is a callback from lwIP, so cyw43_arch_lwip_begin is not required. However,...
Definition: wifi.c:77
err_t wifi_tcp_server_recv(void *p_arg, __unused struct tcp_pcb *p_tpcb, struct pbuf *p_buf, __unused err_t err)
This function is called by lwIP when data is received from a TCP client. It receives the data and che...
Definition: wifi.c:117
void wifi_tcp_server_begin_init(void)
Initializes the TCP server by initializing standard input/output, initializing the CYW43 architecture...
Definition: wifi.c:218
void wifi_run_tcp_server_test(void)
Runs a TCP server and opens it. Then, it enters a loop to check for Wi-Fi driver or lwIP work that ne...
Definition: wifi.c:178
void wifi_tcp_server_begin(void)
Begins a TCP server by connecting to Wi-Fi with the given SSID and password.
Definition: wifi.c:229
struct wifi_tcp_server wifi_tcp_server_t
Struct representing a TCP server connection.