Documentation ¶
Index ¶
- Constants
- Variables
- type DPType
- type DataPoint
- type Device
- func (d *Device) Connect(ctx context.Context) error
- func (d *Device) Disconnect() error
- func (d *Device) GetAddress() string
- func (d *Device) GetDatapoint(id byte) (DataPoint, bool)
- func (d *Device) GetName() string
- func (d *Device) Pair() error
- func (d *Device) SetDatapoint(dp DataPoint) error
- func (d *Device) SetDatapoints(datapoints []DataPoint) error
- func (d *Device) Update() error
- type DiscoveredDevice
- type Discoverer
Constants ¶
View Source
const ( // BLEConnectTimeout is the timeout for connecting to a BLE device BLEConnectTimeout = 25 * time.Second // ResponseWaitTimeout is the timeout for waiting for a response from the device ResponseWaitTimeout = 15 * time.Second // GattMTU is the maximum size of a GATT packet // https://developer.tuya.com/en/docs/iot-device-dev/tuya-ble-sdk-user-guide?id=K9h5zc4e5djd9#title-6-MTU GattMTU = 20 )
View Source
const (
ManufacturerID = 0x07D0
)
Variables ¶
View Source
var ( // https://developer.tuya.com/en/docs/iot-device-dev/tuya-ble-sdk-user-guide?id=K9h5zc4e5djd9#title-5-The%20concepts%20of%20tuya%20ble%20service CharacteristicNotifyUUID = ble.UUID16(0x2b10) CharacteristicWriteUUID = ble.UUID16(0x2b11) ConnectServiceUUID = ble.UUID16(0x1910) )
View Source
var DiscoverServiceUUID = ble.UUID16(0xa201)
Functions ¶
This section is empty.
Types ¶
type DataPoint ¶
DataPoint represents a device data point
func NewDataPoint ¶
NewDataPoint creates a new DataPoint instance
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents a Tuya BLE device
func NewDevice ¶
func NewDevice(address, name, uuid, deviceID, localKey string, logger *slog.Logger) (*Device, error)
NewDevice creates a new Device instance
func (*Device) Disconnect ¶
Disconnect disconnects from the Tuya BLE device
func (*Device) GetAddress ¶
GetAddress returns the device address
func (*Device) GetDatapoint ¶
GetDatapoint returns the requested data point
func (*Device) SetDatapoint ¶
SetDatapointValue sets the value of a data point
func (*Device) SetDatapoints ¶
SetDatapoints sets multiple data points at once
type DiscoveredDevice ¶
type DiscoveredDevice struct { LocalName string Address string IsBound bool ProtocolVersion byte UUID []byte RSSI int }
func (DiscoveredDevice) ID ¶
func (d DiscoveredDevice) ID() string
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
func NewDiscoverer ¶
func NewDiscoverer(logger *slog.Logger) *Discoverer
func (*Discoverer) Discover ¶
func (d *Discoverer) Discover() (<-chan *DiscoveredDevice, func())
func (*Discoverer) DiscoverDevice ¶
func (d *Discoverer) DiscoverDevice(ctx context.Context, address string) (*DiscoveredDevice, error)
Click to show internal directories.
Click to hide internal directories.