Documentation ¶
Overview ¶
Package wifinina implements TCP wireless communication over SPI with an attached separate ESP32 board using the Arduino WiFiNINA protocol.
In order to use this driver, the ESP32 must be flashed with specific firmware from Arduino. For more information: https://github.com/arduino/nina-fw
Index ¶
- Constants
- Variables
- type CommandType
- type ConnectionStatus
- type Device
- func (d *Device) AnalogWrite(pin uint8, value uint8) error
- func (d *Device) CheckDataSent(sock uint8) (bool, error)
- func (d *Device) Configure()
- func (d *Device) ConnectSSLSocket(addr, portStr string) error
- func (d *Device) ConnectTCPSocket(addr, portStr string) error
- func (d *Device) ConnectToAccessPoint(ssid, pass string, timeout time.Duration) error
- func (d *Device) ConnectUDPSocket(addr, portStr, lportStr string) (err error)
- func (d *Device) DigitalWrite(pin uint8, value uint8) error
- func (d *Device) Disconnect() error
- func (d *Device) DisconnectSocket() error
- func (d *Device) GetClientIP() (string, error)
- func (d *Device) GetClientState(sock uint8) (uint8, error)
- func (d *Device) GetConnectionStatus() (ConnectionStatus, error)
- func (d *Device) GetCurrentBSSID() (MACAddress, error)
- func (d *Device) GetCurrentEncryptionType() (EncryptionType, error)
- func (d *Device) GetCurrentRSSI() (int32, error)
- func (d *Device) GetCurrentSSID() (string, error)
- func (d *Device) GetDNS(domain string) (string, error)
- func (d *Device) GetDataBuf(sock uint8, buf []byte) (int, error)
- func (d *Device) GetFwVersion() (string, error)
- func (d *Device) GetHostByName(hostname string) (IPAddress, error)
- func (d *Device) GetIP() (ip, subnet, gateway IPAddress, err error)
- func (d *Device) GetMACAddress() (MACAddress, error)
- func (d *Device) GetNetworkBSSID(idx int) (MACAddress, error)
- func (d *Device) GetNetworkChannel(idx int) (uint8, error)
- func (d *Device) GetNetworkEncrType(idx int) (EncryptionType, error)
- func (d *Device) GetNetworkRSSI(idx int) (int32, error)
- func (d *Device) GetNetworkSSID(idx int) string
- func (d *Device) GetReasonCode() (uint8, error)
- func (d *Device) GetSocket() (uint8, error)
- func (d *Device) GetTemperature() (float32, error)
- func (d *Device) GetTime() (uint32, error)
- func (d *Device) InsertDataBuf(buf []byte, sock uint8) (bool, error)
- func (d *Device) IsConnected() (bool, error)
- func (d *Device) IsSocketDataAvailable() bool
- func (d *Device) ListenAndServe(addr string, handler http.Handler) error
- func (d *Device) PinMode(pin uint8, mode uint8) error
- func (d *Device) Ping(ip IPAddress, ttl uint8) int16
- func (d *Device) ReadSocket(b []byte) (n int, err error)
- func (d *Device) Response(timeout int) ([]byte, error)
- func (d *Device) ScanNetworks() (uint8, error)
- func (d *Device) SendData(buf []byte, sock uint8) (uint16, error)
- func (d *Device) SendUDPData(sock uint8) (bool, error)
- func (d *Device) SetDNS(which uint8, dns1 uint32, dns2 uint32) error
- func (d *Device) SetDebug(on bool) error
- func (d *Device) SetHostname(hostname string) error
- func (d *Device) SetIP(which uint8, ip uint32, gw uint32, subnet uint32) error
- func (d *Device) SetKey(ssid string, index uint8, key string) error
- func (d *Device) SetNetwork(ssid string) error
- func (d *Device) SetNetworkForAP(ssid string) error
- func (d *Device) SetPassphrase(ssid string, passphrase string) error
- func (d *Device) SetPassphraseForAP(ssid string, passphrase string) error
- func (d *Device) SetPowerMode(mode uint8) error
- func (d *Device) StartClient(hostname string, addr uint32, port uint16, sock uint8, mode uint8) error
- func (d *Device) StartScanNetworks() (uint8, error)
- func (d *Device) StartServer(port uint16, sock uint8, mode uint8) error
- func (d *Device) StartSocketSend(size int) error
- func (d *Device) StopClient(sock uint8) error
- func (d *Device) Write(b []byte) (n int, err error)
- type EncryptionType
- type Error
- type IPAddress
- type MACAddress
- type Pin
- type PinConfig
- type PinMode
- type TCPState
Constants ¶
View Source
const ( PinLow uint8 = iota PinHigh )
View Source
const ( ErrTimeoutChipReady Error = 0x01 ErrTimeoutChipSelect Error = 0x02 ErrCheckStartCmd Error = 0x03 ErrWaitRsp Error = 0x04 ErrUnexpectedLength Error = 0xE0 ErrNoParamsReturned Error = 0xE1 ErrIncorrectSentinel Error = 0xE2 ErrCmdErrorReceived Error = 0xEF ErrNotImplemented Error = 0xF0 ErrUnknownHost Error = 0xF1 ErrSocketAlreadySet Error = 0xF2 ErrConnectionTimeout Error = 0xF3 ErrNoData Error = 0xF4 ErrDataNotWritten Error = 0xF5 ErrCheckDataError Error = 0xF6 ErrBufferTooSmall Error = 0xF7 ErrNoSocketAvail Error = 0xFF NoSocketAvail uint8 = 0xFF )
View Source
const ( MaxSockets = 4 MaxNetworks = 10 MaxAttempts = 10 MaxLengthSSID = 32 MaxLengthWPAKey = 63 MaxLengthWEPKey = 13 LengthMacAddress = 6 LengthIPV4 = 4 WlFailure = -1 WlSuccess = 1 )
View Source
const ( FlagCmd = 0 FlagReply = 1 << 7 FlagData = 0x40 NinaCmdPos = 1 NinaParamLenPos = 2 )
View Source
const ( ProtoModeTCP = iota ProtoModeUDP ProtoModeTLS ProtoModeMul )
View Source
const (
ReadBufferSize = 128
)
Variables ¶
View Source
var (
ErrPinNoDevice = errors.New("wifinina pin: device not set")
)
Functions ¶
This section is empty.
Types ¶
type CommandType ¶
type CommandType uint8
const ( CmdStart CommandType = 0xE0 CmdEnd CommandType = 0xEE CmdErr CommandType = 0xEF CmdSetNet CommandType = 0x10 CmdSetPassphrase CommandType = 0x11 CmdSetKey CommandType = 0x12 CmdSetIPConfig CommandType = 0x14 CmdSetDNSConfig CommandType = 0x15 CmdSetHostname CommandType = 0x16 CmdSetPowerMode CommandType = 0x17 CmdSetAPNet CommandType = 0x18 CmdSetAPPassphrase CommandType = 0x19 CmdSetDebug CommandType = 0x1A CmdGetTemperature CommandType = 0x1B CmdGetReasonCode CommandType = 0x1F CmdGetConnStatus CommandType = 0x20 CmdGetIPAddr CommandType = 0x21 CmdGetMACAddr CommandType = 0x22 CmdGetCurrSSID CommandType = 0x23 CmdGetCurrBSSID CommandType = 0x24 CmdGetCurrRSSI CommandType = 0x25 CmdGetCurrEncrType CommandType = 0x26 CmdScanNetworks CommandType = 0x27 CmdStartServerTCP CommandType = 0x28 CmdGetStateTCP CommandType = 0x29 CmdDataSentTCP CommandType = 0x2A CmdAvailDataTCP CommandType = 0x2B CmdGetDataTCP CommandType = 0x2C CmdStartClientTCP CommandType = 0x2D CmdStopClientTCP CommandType = 0x2E CmdGetClientStateTCP CommandType = 0x2F CmdDisconnect CommandType = 0x30 CmdGetIdxRSSI CommandType = 0x32 CmdGetIdxEncrType CommandType = 0x33 CmdReqHostByName CommandType = 0x34 CmdGetHostByName CommandType = 0x35 CmdStartScanNetworks CommandType = 0x36 CmdGetFwVersion CommandType = 0x37 CmdSendDataUDP CommandType = 0x39 CmdGetRemoteData CommandType = 0x3A CmdGetTime CommandType = 0x3B CmdGetIdxBSSID CommandType = 0x3C CmdGetIdxChannel CommandType = 0x3D CmdPing CommandType = 0x3E CmdGetSocket CommandType = 0x3F // All command with DATA_FLAG 0x40 send a 16bit Len CmdSendDataTCP CommandType = 0x44 CmdGetDatabufTCP CommandType = 0x45 CmdInsertDataBuf CommandType = 0x46 // regular format commands CmdSetPinMode CommandType = 0x50 CmdSetDigitalWrite CommandType = 0x51 CmdSetAnalogWrite CommandType = 0x52 )
type ConnectionStatus ¶
type ConnectionStatus uint8
const ( StatusNoShield ConnectionStatus = 255 StatusIdle ConnectionStatus = 0 StatusNoSSIDAvail ConnectionStatus = 1 StatusScanCompleted ConnectionStatus = 2 StatusConnected ConnectionStatus = 3 StatusConnectFailed ConnectionStatus = 4 StatusConnectionLost ConnectionStatus = 5 StatusDisconnected ConnectionStatus = 6 )
type Device ¶
type Device struct { SPI drivers.SPI CS machine.Pin ACK machine.Pin GPIO0 machine.Pin RESET machine.Pin // ResetIsHigh controls if the RESET signal to the processor // should be High or Low (the default). Set this to true // before calling Configure() for boards such as the Arduino MKR 1010, // where the reset signal needs to go high instead of low. ResetIsHigh bool // contains filtered or unexported fields }
func (*Device) Configure ¶
func (d *Device) Configure()
Configure sets the needed pin settings and performs a reset of the WiFi device.
func (*Device) ConnectSSLSocket ¶
func (*Device) ConnectTCPSocket ¶
func (*Device) ConnectToAccessPoint ¶
func (*Device) ConnectUDPSocket ¶
func (*Device) Disconnect ¶
func (*Device) DisconnectSocket ¶
func (*Device) GetClientIP ¶
func (*Device) GetConnectionStatus ¶
func (d *Device) GetConnectionStatus() (ConnectionStatus, error)
func (*Device) GetCurrentBSSID ¶
func (d *Device) GetCurrentBSSID() (MACAddress, error)
func (*Device) GetCurrentEncryptionType ¶
func (d *Device) GetCurrentEncryptionType() (EncryptionType, error)
func (*Device) GetCurrentRSSI ¶
func (*Device) GetCurrentSSID ¶
func (*Device) GetFwVersion ¶
func (*Device) GetMACAddress ¶
func (d *Device) GetMACAddress() (MACAddress, error)
func (*Device) GetNetworkBSSID ¶
func (d *Device) GetNetworkBSSID(idx int) (MACAddress, error)
func (*Device) GetNetworkEncrType ¶
func (d *Device) GetNetworkEncrType(idx int) (EncryptionType, error)
func (*Device) GetNetworkSSID ¶
func (*Device) GetReasonCode ¶
func (*Device) GetTemperature ¶
func (*Device) InsertDataBuf ¶
InsertDataBuf adds data to the buffer used for sending UDP data
func (*Device) IsConnected ¶
func (*Device) IsSocketDataAvailable ¶
IsSocketDataAvailable returns of there is socket data available
func (*Device) ListenAndServe ¶
func (*Device) ScanNetworks ¶
func (*Device) SendUDPData ¶
SendUDPData sends the data previously added to the UDP buffer
func (*Device) SetHostname ¶
func (*Device) SetNetwork ¶
func (*Device) SetNetworkForAP ¶
func (*Device) SetPassphraseForAP ¶
func (*Device) SetPowerMode ¶
func (*Device) StartClient ¶
func (*Device) StartScanNetworks ¶
func (*Device) StartServer ¶
func (*Device) StartSocketSend ¶
func (*Device) StopClient ¶
type EncryptionType ¶
type EncryptionType uint8
const ( EncTypeTKIP EncryptionType = 2 EncTypeCCMP EncryptionType = 4 EncTypeWEP EncryptionType = 5 EncTypeNone EncryptionType = 7 EncTypeAuto EncryptionType = 8 )
type MACAddress ¶
type MACAddress uint64
func (MACAddress) String ¶
func (addr MACAddress) String() string
type TCPState ¶
type TCPState uint8
const ( TCPStateClosed TCPState = 0 TCPStateListen TCPState = 1 TCPStateSynSent TCPState = 2 TCPStateSynRcvd TCPState = 3 TCPStateEstablished TCPState = 4 TCPStateFinWait1 TCPState = 5 TCPStateFinWait2 TCPState = 6 TCPStateCloseWait TCPState = 7 TCPStateClosing TCPState = 8 TCPStateLastACK TCPState = 9 TCPStateTimeWait TCPState = 10 )
Click to show internal directories.
Click to hide internal directories.