From 2a48b5c25db6099c9878e21bc259ce19378d8180 Mon Sep 17 00:00:00 2001 From: Kenneth Bell Date: Tue, 13 Apr 2021 19:15:42 -0700 Subject: [PATCH] wifinina: fix getMACAddress and getTime Tested against Adafruit AirLift (compatibile variant of wifinina) --- wifinina/wifinina.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wifinina/wifinina.go b/wifinina/wifinina.go index ed572a6..cc84d3f 100644 --- a/wifinina/wifinina.go +++ b/wifinina/wifinina.go @@ -557,8 +557,9 @@ func (d *Device) GetReasonCode() (uint8, error) { return d.getUint8(d.req0(CmdGetReasonCode)) } -func (d *Device) GetTime() (string, error) { - return d.getString(d.req0(CmdGetTime)) +// GetTime is the time as a Unix timestamp +func (d *Device) GetTime() (uint32, error) { + return d.getUint32(d.req0(CmdGetTime)) } func (d *Device) GetTemperature() (float32, error) { @@ -734,7 +735,7 @@ func (d *Device) getMACAddress(l uint8, err error) (MACAddress, error) { if l != 6 { return 0, ErrUnexpectedLength } - return MACAddress(binary.LittleEndian.Uint64(d.buf[0:8]) >> 16), err + return MACAddress(binary.LittleEndian.Uint64(d.buf[0:8]) & 0xFFFFFFFFFFFF), err } // req0 sends a command to the device with no request parameters