-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* begin restructuring packages * use seqs library * refactor API * add working DHCP using seqs * polling inside NIC loop * begin TCP transactions * keep working on TCP server * almost done; work to be done on seqs side * relatively sleek TCP interaction * bump seqs version so is buildable * bump seqs version to latest with new DHCP and reduced stack usage * better logging API * move legacy files * rename cyrw->cyw43439 * move cyrw files into root directory
- Loading branch information
Showing
76 changed files
with
655 additions
and
6,452 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//go:build tinygo | ||
|
||
package cyw43439 | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"machine" | ||
|
||
"log/slog" | ||
) | ||
|
||
const ( | ||
verbose_debug = true | ||
initReadback = false | ||
validateDownloads = false | ||
LevelDebugIO = slog.LevelDebug | ||
defaultLevel = LevelDebugIO | ||
) | ||
|
||
func (d *Device) debugIO(msg string, attrs ...slog.Attr) { | ||
d.log.LogAttrs(context.Background(), LevelDebugIO, msg, attrs...) | ||
} | ||
|
||
func (d *Device) debug(msg string, attrs ...slog.Attr) { | ||
d.log.LogAttrs(context.Background(), slog.LevelDebug, msg, attrs...) | ||
} | ||
|
||
func (d *Device) info(msg string, attrs ...slog.Attr) { | ||
d.log.LogAttrs(context.Background(), slog.LevelInfo, msg, attrs...) | ||
} | ||
|
||
func (d *Device) logError(msg string, attrs ...slog.Attr) { | ||
d.log.LogAttrs(context.Background(), slog.LevelError, msg, attrs...) | ||
} | ||
|
||
func (d *Device) SetLogger(log *slog.Logger) { | ||
d.log = log | ||
} | ||
|
||
func _setDefaultLogger(d *Device) { | ||
writer := machine.Serial | ||
handler := slog.NewTextHandler(writer, &slog.HandlerOptions{Level: defaultLevel}) | ||
// Small slog handler implemented on our side: | ||
// smallHandler := &handler{w: writer, level: slog.LevelDebug} | ||
d.log = slog.New(handler) | ||
} | ||
|
||
var _ slog.Handler = (*handler)(nil) | ||
|
||
// handler implements slog.Handler interface minimally. | ||
type handler struct { | ||
level slog.Level | ||
w io.Writer | ||
buf [256]byte | ||
} | ||
|
||
func (h *handler) Enabled(_ context.Context, level slog.Level) bool { return level >= h.level } | ||
|
||
func (h *handler) Handle(_ context.Context, r slog.Record) error { | ||
n := copy(h.buf[:len(h.buf)-2], r.Message) | ||
h.buf[n] = '\n' | ||
_, err := h.w.Write(h.buf[:n+1]) | ||
return err | ||
} | ||
func (h *handler) WithAttrs(attrs []slog.Attr) slog.Handler { | ||
return nil | ||
} | ||
func (h *handler) WithGroup(name string) slog.Handler { | ||
return nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.