Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions drivers/wireless/cyw43439.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const assert = std.debug.assert;

const Bus = @import("cyw43439/bus.zig");
const WiFi = @import("cyw43439/wifi.zig");
pub const JoinOptions = WiFi.JoinOptions;

const log = std.log.scoped(.cyw43);

Expand All @@ -27,7 +28,7 @@ pub fn init(
self.mac = try self.read_mac();
}

pub fn join(self: *Self, ssid: []const u8, pwd: []const u8, opt: WiFi.JoinOptions) !void {
pub fn join(self: *Self, ssid: []const u8, pwd: []const u8, opt: JoinOptions) !void {
try self.wifi.join(ssid, pwd, opt);
}

Expand Down Expand Up @@ -80,14 +81,6 @@ pub const Pin = struct {
pin: u2,
wifi: *WiFi,

pub fn get(self: *Pin) bool {
return self.wifi.gpio_get(self.pin);
}

pub fn put(self: *Pin, value: u1) void {
self.wifi.gpio_set(self.pin, value);
}

pub fn toggle(self: *Pin) void {
self.wifi.gpio_toggle(self.pin);
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/wireless/cyw43439/ioctl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ pub const Response = struct {
zero.msg.event_type = .none;
return zero;
}
var evt: EventPacket = @bitCast(buf[0..@sizeOf(EventPacket)].*);
var evt: EventPacket = undefined;
@memcpy(std.mem.asBytes(&evt), buf[0..@sizeOf(EventPacket)]);
std.mem.byteSwapAllFields(EventPacket, &evt);
return evt;
}
Expand Down
12 changes: 3 additions & 9 deletions drivers/wireless/cyw43439/wifi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ fn join_wait(self: *Self, wait_ms: u32, security: JoinOptions.Security) !void {
var bytes: [512]u8 align(4) = undefined;

while (delay < wait_ms) {
// self.log_read();
// self.log_read(); // show chip logs
const rsp = try self.read(&bytes) orelse {
self.sleep_ms(ioctl.response_poll_interval);
delay += ioctl.response_poll_interval;
Expand All @@ -427,10 +427,6 @@ fn join_wait(self: *Self, wait_ms: u32, security: JoinOptions.Security) !void {
switch (rsp.sdp.channel()) {
.event => {
const evt = rsp.event().msg;
// log.debug(
// " event type: {s:<15}, status: {s} flags: {x}",
// .{ @tagName(evt.event_type), @tagName(evt.status), evt.flags },
// );
switch (evt.event_type) {
.link => {
if (evt.flags & 1 == 0) return error.Cyw43JoinLinkDown;
Expand All @@ -456,26 +452,24 @@ fn join_wait(self: *Self, wait_ms: u32, security: JoinOptions.Security) !void {
else => {},
}
if (set_ssid and link_up and link_auth) {
//log.debug("join OK", .{});
return;
}
},
else => self.log_response(rsp),
else => {},
}
}
return error.Cyw43JoinTimeout;
}

// show unexpected command response
// can be assert also
fn log_response(self: *Self, rsp: ioctl.Response) void {
_ = self;
switch (rsp.sdp.channel()) {
.event => {
const evt = rsp.event().msg;
if (evt.event_type == .none and evt.status == .success)
return;
log.info(
log.debug(
"unhandled event type: {}, status: {} ",
.{ evt.event_type, evt.status },
);
Expand Down
5 changes: 4 additions & 1 deletion examples/raspberrypi/rp2xxx/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ pub fn build(b: *std.Build) void {
.{ .name = "ssd1306", .file = "src/ssd1306_oled.zig", .imports = &.{
.{ .name = "font8x8", .module = font8x8_dep.module("font8x8") },
} },
.{ .name = "net-dhcp", .file = "src/net/dhcp.zig" },
.{ .name = "net-pong", .file = "src/net/pong.zig" },
.{ .name = "net-udp", .file = "src/net/udp.zig" },
.{ .name = "net-tcp_client", .file = "src/net/tcp_client.zig" },
.{ .name = "net-tcp_server", .file = "src/net/tcp_server.zig" },
};

var available_examples: std.array_list.Managed(Example) = .init(b.allocator);
Expand Down
7 changes: 5 additions & 2 deletions examples/raspberrypi/rp2xxx/src/net/lwip/include/lwipopts.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// all available options:
// https://github.com/lwip-tcpip/lwip/blob/STABLE-2_1_3_RELEASE/src/include/lwip/opt.h
//
#ifndef lwipopts_h
#define lwipopts_h

Expand Down Expand Up @@ -37,9 +40,9 @@
#define MEMP_NUM_SYS_TIMEOUT 16

// callbacks
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 0
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
#define LWIP_NETIF_EXT_STATUS_CALLBACK 0

// stats
#define LWIP_STATS 1
Expand Down
Loading
Loading