Skip to content

Commit 5b0289f

Browse files
committed
RTOS bug fixing and update example to use Signal
1 parent ba1584c commit 5b0289f

2 files changed

Lines changed: 123 additions & 208 deletions

File tree

examples/espressif/esp/src/tcp_server.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const SERVER_PORT = 3333;
5252

5353
var maybe_netif: ?*lwip.c.netif = null;
5454

55-
var ip_ready_semaphore: rtos.Semaphore = .init(0, 1);
55+
var ip_ready_signal: rtos.Signal(void) = .{};
5656
var ip: lwip.c.ip_addr_t = undefined;
5757

5858
extern fn netconn_new_with_proto_and_callback(t: lwip.c.enum_netconn_type, proto: lwip.c.u8_t, callback: ?*const anyopaque) [*c]lwip.c.struct_netconn;
@@ -103,9 +103,10 @@ pub fn main() !void {
103103
}
104104

105105
try radio.wifi.connect_blocking();
106+
106107
try lwip.c_err(lwip.c.netifapi_netif_common(&netif, lwip.c.netif_set_link_up, null));
107108

108-
ip_ready_semaphore.take();
109+
ip_ready_signal.wait();
109110
std.log.info("Listening on {f}:{}", .{ IP_Formatter.init(netif.ip_addr), SERVER_PORT });
110111

111112
const server_conn = netconn_new_with_proto_and_callback(lwip.c.NETCONN_TCP, 0, null) orelse {
@@ -201,7 +202,7 @@ fn netif_status_callback(netif_ptr: [*c]lwip.c.netif) callconv(.c) void {
201202
const netif = &netif_ptr[0];
202203
if (netif.ip_addr.u_addr.ip4.addr != 0) {
203204
ip = netif.ip_addr;
204-
ip_ready_semaphore.give();
205+
ip_ready_signal.put({});
205206
}
206207
}
207208

0 commit comments

Comments
 (0)