mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-22 07:29:01 +00:00
Client driver for WiFiNINA firmware (#98)
* wifinina: implementation of WiFiNINA driver, including: - TCP client example is working - reading sockets and mqtt working - switched over to common net package also used by espat package - smoke tests and updated README for wifinina
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package wifinina
|
||||
|
||||
import "time"
|
||||
|
||||
func wait(duration time.Duration) {
|
||||
newTimer(duration).WaitUntilExpired()
|
||||
}
|
||||
|
||||
type timer struct {
|
||||
start int64
|
||||
interval int64
|
||||
}
|
||||
|
||||
func newTimer(interval time.Duration) timer {
|
||||
return timer{
|
||||
start: time.Now().UnixNano(),
|
||||
interval: int64(interval),
|
||||
}
|
||||
}
|
||||
|
||||
func (t timer) Expired() bool {
|
||||
return time.Now().UnixNano() > (t.start + t.interval)
|
||||
}
|
||||
|
||||
func (t timer) WaitUntilExpired() {
|
||||
for !t.Expired() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user