Documentation ¶
Index ¶
- type Customer
- type Device
- type DeviceCredentials
- type GetTenantDevices
- type TBError
- type Thingsboard
- func (tb *Thingsboard) Connect() error
- func (tb *Thingsboard) Disconnect() error
- func (tb *Thingsboard) GetDeviceAccessTokenByID(deviceID string) (string, error)
- func (tb *Thingsboard) GetDeviceAccessTokenByName(deviceName string) (string, error)
- func (tb *Thingsboard) GetDeviceByID(deviceID string) (*Device, error)
- func (tb *Thingsboard) GetDeviceByName(name string) (*Device, error)
- func (tb *Thingsboard) GetDeviceCredentialsByDeviceID(deviceID string) (*DeviceCredentials, error)
- func (tb *Thingsboard) GetDeviceCredentialsByDeviceName(name string) (*DeviceCredentials, error)
- func (tb *Thingsboard) GetDevicesByIds(deviceIDs string) ([]Device, error)
- func (tb *Thingsboard) GetTenantDevice(name string) (*Device, error)
- func (tb *Thingsboard) GetTenantDevices(pageSize int, page int) (GetTenantDevices, error)
- func (tb *Thingsboard) SaveTelemetry(deviceToken string, telemetryData interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { ID entityID `json:"id"` TenantID entityID `json:"tenantId"` CustomerID entityID `json:"customerId"` CreatedTime int64 `json:"createdTime"` AdditionalInfo struct { Gateway bool `json:"gateway"` Description string `json:"description"` } `json:"additionalInfo"` Name string `json:"name"` Type string `json:"type"` Label string `json:"label"` }
Device structure to hold information about devices
type DeviceCredentials ¶
type DeviceCredentials struct { CreatedTime int `json:"createdTime"` CredentialsID string `json:"credentialsId"` // ['ACCESS_TOKEN', 'X509_CERTIFICATE']stringEnum:"ACCESS_TOKEN", "X509_CERTIFICATE", CredentialsType string `json:"credentialsType"` CredentialsValue string `json:"credentialsValue"` DeviceID entityID `json:"deviceId"` ID entityID `json:"id"` // DeviceCredentialsId }
DeviceCredentials struct to hold getDeviceCredentialsByDeviceId() repsponse
type GetTenantDevices ¶
type GetTenantDevices struct { Data []Device `json:"data"` TotalPages int `json:"totalPages"` TotalElements int `json:"totalElements"` HasNext bool `json:"hasNext"` }
GetTenantDevices represents structure for GetTenantDevices() method
type TBError ¶
type TBError struct { Timestamp string `json:"timestamp"` // * Status int `json:"status"` // * Message string `json:"message"` // * Code int `json:"errorCode"` Type string `json:"error"` Path string `json:"path"` }
TBError holds and parses Thingboard JSON error response * - Field is always present in JSON error response
type Thingsboard ¶
type Thingsboard struct { Auth *jsonAuth User *jsonUser // contains filtered or unexported fields }
Thingsboard ...
func New ¶
func New(host string, user string, pass string) (*Thingsboard, error)
New returns new Thingsboard instance
func (*Thingsboard) Connect ¶
func (tb *Thingsboard) Connect() error
Connect is used by New() method to connect to Thingsboard server.
func (*Thingsboard) Disconnect ¶
func (tb *Thingsboard) Disconnect() error
Disconnect should logout, remove currently authenticated user (authorization for token should be removed). But it dosn't work at all on Thingsboard.
func (*Thingsboard) GetDeviceAccessTokenByID ¶
func (tb *Thingsboard) GetDeviceAccessTokenByID(deviceID string) (string, error)
GetDeviceAccessTokenByID returns Acccess Token for Device with specified name
func (*Thingsboard) GetDeviceAccessTokenByName ¶
func (tb *Thingsboard) GetDeviceAccessTokenByName(deviceName string) (string, error)
GetDeviceAccessTokenByName returns Acccess Token for Device with specified name
func (*Thingsboard) GetDeviceByID ¶
func (tb *Thingsboard) GetDeviceByID(deviceID string) (*Device, error)
GetDeviceByID GET /api/device/{deviceId} TODO: HTTP Request codes
func (*Thingsboard) GetDeviceByName ¶
func (tb *Thingsboard) GetDeviceByName(name string) (*Device, error)
GetDeviceByName (by Name!) GET /api/tenant/devices{?deviceName}
func (*Thingsboard) GetDeviceCredentialsByDeviceID ¶
func (tb *Thingsboard) GetDeviceCredentialsByDeviceID(deviceID string) (*DeviceCredentials, error)
GetDeviceCredentialsByDeviceID returns device credentials structure GET /api/device/{deviceId}/credentials
func (*Thingsboard) GetDeviceCredentialsByDeviceName ¶
func (tb *Thingsboard) GetDeviceCredentialsByDeviceName(name string) (*DeviceCredentials, error)
GetDeviceCredentialsByDeviceName returns Access Token for Device (by name)
func (*Thingsboard) GetDevicesByIds ¶
func (tb *Thingsboard) GetDevicesByIds(deviceIDs string) ([]Device, error)
GetDevicesByIds GET /api/devices{?deviceIds}
func (*Thingsboard) GetTenantDevice ¶
func (tb *Thingsboard) GetTenantDevice(name string) (*Device, error)
GetTenantDevice is an alias of GetDeviceByName() - compatibility with TB Swagger
func (*Thingsboard) GetTenantDevices ¶
func (tb *Thingsboard) GetTenantDevices(pageSize int, page int) (GetTenantDevices, error)
GetTenantDevices downloads information about currently logged user devices available in his Tenant GET /api/tenant/devices{?type,textSearch,sortProperty,sortOrder,*pageSize,*page} 401 Unauthorized 403 Forbidden 404 Not Found
func (*Thingsboard) SaveTelemetry ¶
func (tb *Thingsboard) SaveTelemetry(deviceToken string, telemetryData interface{}) error
SaveTelemetry uploads Telemetry to ThingsBoard, by deviceID