12345678910111213141516171819202122232425262728293031323334353637383940 |
- package iot
- /*
- ArozOS IoT Handler
- This handler provide adaptive functions to different protocol based IoT devices
- (aka this is just a wrapper class. See independent IoT module for more information)
- */
- //Defination of a control endpoint
- type Endpoint struct {
- RelPath string //Relative path for this endpoint. If the access path is 192.168.0.100:8080/api1, then this value should be /api1
- Name string //Name of the this endpoint. E.g. "Toggle Light"
- Desc string //Description of function. E.g. "Toggle the ligh on and off"
- }
- //Defination of an IoT device
- type Device struct {
- Name string //Name of the device
- Model string //Model number of the device
- Version string //Device firmware
- Manufacturer string //<amifacturer of device
- DeviceUUID string //Device UUID
- IPAddr string //IP address of the device
- RequireAuth bool //Require authentication or public accessable.
- RequireConnect bool //Require pre-connection before use
- Status map[string]interface{} //Status of the device, support multi channels
- ControlEndpoints []*Endpoint //Endpoints avabile for this device
- SourceHandler *ProtocolHandler //The source handler that this device is scanned / discovered by
- }
- type ProtocolHandler interface {
- Scan() ([]*Device, error) //Scan the nearby devices
- List() ([]*Device, error) //Return the previous scanned list
- Connect(device *Device) error //Connect to the device
- Status(device *Device) (map[string]string, error) //Get status of the IoT device //Connect to a given device
- Execute(device *Device, endpoint *Endpoint, payload interface{}) (interface{}, error) //Execute an endpoint for a device
- Disconnect(device *Device) error //Disconnect from a device connection
- }
|