device

package
v0.0.0-...-0aa8592 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2025 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandResponseTimeoutLong_s  = 60
	CommandResponseTimeoutShort_s = 30
	ConnectResponseTimeout_s      = 200
)
View Source
const (
	MaxRetriesFlashProvSketch    = 5
	MaxRetriesProvisioningResult = 20
)

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, params *DeleteParams, cred *config.Credentials) error

Delete command is used to delete a device from Arduino IoT Cloud.

func GetInputFromMenu

func GetInputFromMenu(config *NetConfig) error

func NetConfigure

func NetConfigure(ctx context.Context, boardFilters *CreateParams, NetConfig *NetConfig) error

Types

type CATM1Setting

type CATM1Setting struct {
	PIN   string    `json:"pin"`   // Max length of pin is 8 + \0
	APN   string    `json:"apn"`   // Max length of apn is 100 + \0
	Login string    `json:"login"` // Max length of login is 32 + \0
	Pass  string    `json:"pass"`  // Max length of pass is 32 + \0
	Band  [4]uint32 `json:"band"`
}

type CellularSetting

type CellularSetting struct {
	PIN   string `json:"pin"`   // Max length of pin is 8 + \0
	APN   string `json:"apn"`   // Max length of apn is 100 + \0
	Login string `json:"login"` // Max length of login is 32 + \0
	Pass  string `json:"pass"`  // Max length of pass is 32 + \0
}

type ConfigStatus

type ConfigStatus int
const (
	NoneState ConfigStatus = iota
	WaitForConnection
	WaitingForInitialStatus
	WaitingForNetworkOptions
	BoardReady
	FlashProvisioningSketch
	GetSketchVersionRequest
	WaitingSketchVersion
	WiFiFWVersionRequest
	WaitingWiFiFWVersion
	RequestBLEMAC
	WaitBLEMAC
	SendInitialTS
	MissingParameter
	IDRequest
	WaitingID
	WaitingSignature
	WaitingPublicKey
	ClaimDevice
	RegisterDevice
	RequestReset
	WaitResetResponse
	GetNetConfigLibVersionRequest
	WaitingNetConfigLibVersion
	ConfigureNetwork
	SendConnectionRequest
	WaitingForConnectionCommandResult
	WaitingForNetworkConfigResult
	WaitingForProvisioningResult
	UnclaimDevice
	End
	ErrorState
)

This enum represents the different states of the network configuration process of the Arduino Board Configuration Protocol.

type ConfigurationStates

type ConfigurationStates struct {
	// contains filtered or unexported fields
}

func (*ConfigurationStates) ConfigureNetwork

func (cs *ConfigurationStates) ConfigureNetwork(ctx context.Context, c *NetConfig) (ConfigStatus, error)

func (*ConfigurationStates) HandleStatusMessage

func (c *ConfigurationStates) HandleStatusMessage(status int16) (ConfigStatus, error)

func (*ConfigurationStates) SendConnectionRequest

func (c *ConfigurationStates) SendConnectionRequest() (ConfigStatus, error)

func (*ConfigurationStates) WaitForConnection

func (c *ConfigurationStates) WaitForConnection() (ConfigStatus, error)

func (*ConfigurationStates) WaitingForConnectionCommandResult

func (c *ConfigurationStates) WaitingForConnectionCommandResult() (ConfigStatus, error)

func (*ConfigurationStates) WaitingForInitialStatus

func (c *ConfigurationStates) WaitingForInitialStatus() (ConfigStatus, error)

func (*ConfigurationStates) WaitingForNetworkConfigResult

func (c *ConfigurationStates) WaitingForNetworkConfigResult() (ConfigStatus, error)

func (*ConfigurationStates) WaitingForNetworkOptions

func (c *ConfigurationStates) WaitingForNetworkOptions() (ConfigStatus, error)

In this state the cli is waiting for the available network options as specified in the Arduino Board Configuration Protocol.

type ConnectedBoardInfos

type ConnectedBoardInfos struct {
	UHWID         string
	PublicKey     string
	Signature     string
	BLEMacAddress string
}

type CreateGenericParams

type CreateGenericParams struct {
	Name string // Device name
	FQBN string // Board FQBN
}

CreateGenericParams contains the parameters needed to create a new generic device.

type CreateLoraParams

type CreateLoraParams struct {
	CreateParams
	FrequencyPlan string
}

CreateLoRaParams contains the parameters needed to provision a LoRa device.

type CreateParams

type CreateParams struct {
	Name           string  // Device name
	Port           *string // Serial port - Optional - If omitted then each serial port is analyzed
	FQBN           *string // Board FQBN - Optional - If omitted then the first device found gets selected
	ConnectionType *string // Connection type - Optional - If omitted then the default connection type (depends on the board type) get selected
}

CreateParams contains the parameters needed to find the device to be provisioned.

type DeleteParams

type DeleteParams struct {
	ID   *string
	Tags map[string]string
}

DeleteParams contains the parameters needed to delete a device from Arduino IoT Cloud. ID and Tags parameters are mutually exclusive and one among them is required: An error is returned if they are both nil or if they are both not nil.

type DeviceGenericInfo

type DeviceGenericInfo struct {
	DeviceInfo
	Password string `json:"secret_key"`
}

DeviceGenericInfo contains the most interesting parameters of a generic Arduino IoT Cloud device.

func CreateGeneric

func CreateGeneric(ctx context.Context, params *CreateGenericParams, cred *config.Credentials) (*DeviceGenericInfo, error)

CreateGeneric command is used to add a new generic device to Arduino IoT Cloud.

type DeviceInfo

type DeviceInfo struct {
	Name           string   `json:"name"`
	ID             string   `json:"id"`
	Board          string   `json:"board"`
	Serial         string   `json:"serial_number"`
	FQBN           string   `json:"fqbn"`
	Tags           []string `json:"tags,omitempty"`
	Status         *string  `json:"status,omitempty"`
	Type           string   `json:"type,omitempty"`
	ConnectionType *string  `json:"connection_type,omitempty"`
	ThingID        *string  `json:"thing_id,omitempty"`
}

DeviceInfo contains the most interesting parameters of an Arduino IoT Cloud device.

func Create

func Create(ctx context.Context, params *CreateParams, cred *config.Credentials) (*DeviceInfo, error)

Create command is used to provision a new arduino device and to add it to Arduino IoT Cloud.

func List

func List(ctx context.Context, params *ListParams, cred *config.Credentials) ([]DeviceInfo, error)

List command is used to list the devices of Arduino IoT Cloud.

func Show

func Show(ctx context.Context, deviceId string, cred *config.Credentials) (*DeviceInfo, []netCredentials, error)

List command is used to list the devices of Arduino IoT Cloud.

type DeviceLoraInfo

type DeviceLoraInfo struct {
	DeviceInfo
	AppEUI string `json:"app_eui"`
	AppKey string `json:"app_key"`
	EUI    string `json:"eui"`
}

DeviceLoraInfo contains the most interesting parameters of an Arduino IoT Cloud LoRa device.

func CreateLora

func CreateLora(ctx context.Context, params *CreateLoraParams, cred *config.Credentials) (*DeviceLoraInfo, error)

CreateLora command is used to provision a new LoRa arduino device and to add it to Arduino IoT Cloud.

type EthernetSetting

type EthernetSetting struct {
	IP              IPAddr `json:"ip"`
	DNS             IPAddr `json:"dns"`
	Gateway         IPAddr `json:"gateway"`
	Netmask         IPAddr `json:"netmask"`
	Timeout         uint   `json:"timeout"`
	ResponseTimeout uint   `json:"response_timeout"`
}

type FQBNInfo

type FQBNInfo struct {
	Value   string `json:"fqbn"`
	Name    string `json:"name"`
	Package string `json:"package"`
}

FQBNInfo contains the details of a FQBN.

func ListFQBN

func ListFQBN(ctx context.Context) ([]FQBNInfo, error)

ListFQBN command returns a list of the supported FQBN.

type FrequencyPlanInfo

type FrequencyPlanInfo struct {
	Name     string `json:"name"`
	ID       string `json:"id"`
	Advanced string `json:"advanced"`
}

FrequencyPlanInfo describes a LoRa frequency plan.

func ListFrequencyPlans

func ListFrequencyPlans(ctx context.Context, cred *config.Credentials) ([]FrequencyPlanInfo, error)

ListFrequencyPlans command is used to list the supported LoRa frequency plans.

type IPAddr

type IPAddr struct {
	Type  uint8    `json:"type"`
	Bytes [16]byte `json:"bytes"`
}

type ListParams

type ListParams struct {
	Tags      map[string]string // If tags are provided, only devices that have all these tags are listed.
	DeviceIds string            // If ids are provided, only devices with these ids are listed.
	Status    string            // If status is provided, only devices with this status are listed.
}

ListParams contains the optional parameters needed to filter the devices to be listed.

type LoraSetting

type LoraSetting struct {
	AppEUI      string `json:"appeui"` // appeui is 8 octets * 2 (hex format) + \0
	AppKey      string `json:"appkey"` // appeui is 16 octets * 2 (hex format) + \0
	Band        uint8  `json:"band"`
	ChannelMask string `json:"channel_mask"`
	DeviceClass string `json:"device_class"`
}

type NetConfig

type NetConfig struct {
	Type            int32           `json:"type"`
	WiFi            WiFiSetting     `json:"wifi,omitempty"`
	Eth             EthernetSetting `json:"eth,omitempty"`
	NB              CellularSetting `json:"nb,omitempty"`
	GSM             CellularSetting `json:"gsm,omitempty"`
	CATM1           CATM1Setting    `json:"catm1,omitempty"`
	CellularSetting CellularSetting `json:"cellular,omitempty"`
	Lora            LoraSetting     `json:"lora,omitempty"`
}

type NetworkConfigure

type NetworkConfigure struct {
	// contains filtered or unexported fields
}

func (*NetworkConfigure) Run

func (nc *NetworkConfigure) Run(ctx context.Context, netConfig *NetConfig) error

type ProvisionV2

type ProvisionV2 struct {
	arduino.Commander
	// contains filtered or unexported fields
}

func NewProvisionV2

func NewProvisionV2(comm *arduino.Commander, iotClient *iotapiraw.IoTApiRawClient, credentials *config.Credentials, extInterface transport.TransportInterface) *ProvisionV2

func (*ProvisionV2) GetProvisioningResult

func (p *ProvisionV2) GetProvisioningResult() (string, error)

* The function return the Arduino Cloud Device ID of the new created board * if the process ends successfully. Otherwise, an error

func (*ProvisionV2) Run

type ProvisioningV2BoardParams

type ProvisioningV2BoardParams struct {
	// contains filtered or unexported fields
}

type WiFiSetting

type WiFiSetting struct {
	SSID string `json:"ssid"` // Max length of ssid is 32 + \0
	PWD  string `json:"pwd"`  // Max length of password is 63 + \0
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL