Documentation ¶
Index ¶
- Constants
- func DeleteDeviceActivity(ctx context.Context, dev devices.Core)
- func GenDeviceTopicKey(dev devices.Core) string
- func GetActivityDevices(ctx context.Context) (map[devices.Core]struct{}, error)
- func UpdateDeviceActivity(ctx context.Context, dev devices.Core)
- func UpdatesDeviceActivity(ctx context.Context, devs []devices.Core)
- type CloudProtocol
- func (p *CloudProtocol[pConf]) ConfigChange(ctx context.Context, opt ConfigOpt, c pConf) error
- func (p *CloudProtocol[pConf]) GetAllConf() (ret []pConf)
- func (p *CloudProtocol[pConf]) GetConf(key string) *pConf
- func (p *CloudProtocol[pConf]) RegisterConfigChange() error
- func (p *CloudProtocol[pConf]) RegisterDeviceSync(fieldName string, f SyncDevicesFunc[pConf]) error
- func (p *CloudProtocol[pConf]) RegisterInitHandler(handle func(conf pConf) (close func(), err error)) error
- func (p *CloudProtocol[pConf]) ReportDevConn(ctx context.Context, conn devices.DevConn) (err error)
- func (p *CloudProtocol[pConf]) Start() error
- func (p *CloudProtocol[pConf]) UpdateConfig(ctx context.Context, c []pConf) error
- type CloudProtocolConf
- type ConfImp
- type ConfInfo
- type ConfigOpt
- type ConnHandle
- type ConnectMsg
- type DefaultConf
- type DevHandle
- type LightProtocol
- func (p *LightProtocol) DevPubMsg(ctx context.Context, publishMsg *devices.DevPublish) error
- func (p *LightProtocol) GetProductID(productID string) string
- func (p *LightProtocol) GetUnitedRhinoProductIDs() []string
- func (p *LightProtocol) RegisterDeviceMsgDownHandler(handle func(ctx context.Context, info *devices.InnerPublish) error) error
- func (p *LightProtocol) RegisterProductIDSync() error
- func (p *LightProtocol) RegisterTimerHandler(f func(ctx context.Context, t time.Time) error) error
- func (p *LightProtocol) RunTimerHandles()
- func (p *LightProtocol) Start() error
- type LightProtocolConf
- type LightSvrClient
- type MqttProtocol
- type SyncDevicesFunc
Constants ¶
View Source
const ( DeviceMqttDevice = "device:mqtt:device" DeviceMqttClientID = "device:mqtt:clientID" DeviceLastActivity = "device:lastActivity" )
Variables ¶
This section is empty.
Functions ¶
func GenDeviceTopicKey ¶
func GetActivityDevices ¶
Types ¶
type CloudProtocol ¶
type CloudProtocol[pConf ConfImp] struct { ConfMap map[string]ConfInfo[pConf] ConfMapMutex sync.RWMutex SyncDevices SyncDevicesFunc[pConf] InitFunc func(conf pConf) (close func(), err error) *LightProtocol }
func NewCloudProtocol ¶
func NewCloudProtocol[pConf ConfImp](c conf.EventConf, pi *dm.ProtocolInfo, pc *CloudProtocolConf[pConf]) (*CloudProtocol[pConf], error)
func (*CloudProtocol[pConf]) ConfigChange ¶
func (p *CloudProtocol[pConf]) ConfigChange(ctx context.Context, opt ConfigOpt, c pConf) error
func (*CloudProtocol[pConf]) GetAllConf ¶
func (p *CloudProtocol[pConf]) GetAllConf() (ret []pConf)
func (*CloudProtocol[pConf]) GetConf ¶
func (p *CloudProtocol[pConf]) GetConf(key string) *pConf
func (*CloudProtocol[pConf]) RegisterConfigChange ¶
func (p *CloudProtocol[pConf]) RegisterConfigChange() error
func (*CloudProtocol[pConf]) RegisterDeviceSync ¶
func (p *CloudProtocol[pConf]) RegisterDeviceSync(fieldName string, f SyncDevicesFunc[pConf]) error
func (*CloudProtocol[pConf]) RegisterInitHandler ¶
func (p *CloudProtocol[pConf]) RegisterInitHandler( handle func(conf pConf) (close func(), err error)) error
func (*CloudProtocol[pConf]) ReportDevConn ¶
func (*CloudProtocol[pConf]) Start ¶
func (p *CloudProtocol[pConf]) Start() error
func (*CloudProtocol[pConf]) UpdateConfig ¶
func (p *CloudProtocol[pConf]) UpdateConfig(ctx context.Context, c []pConf) error
type CloudProtocolConf ¶
type ConnHandle ¶
type ConnectMsg ¶
type ConnectMsg struct { UserName string `json:"username"` Ts int64 `json:"ts"` Address string `json:"ipaddress"` ClientID string `json:"clientid"` Reason string `json:"reason"` }
登录登出消息
type DefaultConf ¶
type DefaultConf struct { }
func (DefaultConf) Equal ¶
func (p DefaultConf) Equal(in DefaultConf) bool
func (DefaultConf) GenKey ¶
func (p DefaultConf) GenKey() string
type LightProtocol ¶
type LightProtocol struct { FastEvent *eventBus.FastEvent Pi *dm.ProtocolInfo ServerName string ProductIDMap map[string]string //key 是外部的产品ID,value是内部的产品ID UnitedRhinoProductIDs []string //iThings 的产品ID列表 ProductIDMapMutex sync.RWMutex LightSvrClient ThirdProductIDFieldName devices.ProtocolKey // contains filtered or unexported fields }
func NewLightProtocol ¶
func NewLightProtocol(c conf.EventConf, pi *dm.ProtocolInfo, pc *LightProtocolConf) (*LightProtocol, error)
func (*LightProtocol) DevPubMsg ¶
func (p *LightProtocol) DevPubMsg(ctx context.Context, publishMsg *devices.DevPublish) error
func (*LightProtocol) GetProductID ¶
func (p *LightProtocol) GetProductID(productID string) string
通过外部的产品iD查询联犀的产品iD
func (*LightProtocol) GetUnitedRhinoProductIDs ¶ added in v0.2.3
func (p *LightProtocol) GetUnitedRhinoProductIDs() []string
func (*LightProtocol) RegisterDeviceMsgDownHandler ¶
func (p *LightProtocol) RegisterDeviceMsgDownHandler( handle func(ctx context.Context, info *devices.InnerPublish) error) error
func (*LightProtocol) RegisterProductIDSync ¶
func (p *LightProtocol) RegisterProductIDSync() error
func (*LightProtocol) RegisterTimerHandler ¶
定时同步设备信息,产品信息 如果不需要可以不注册
func (*LightProtocol) RunTimerHandles ¶
func (p *LightProtocol) RunTimerHandles()
func (*LightProtocol) Start ¶
func (p *LightProtocol) Start() error
type LightProtocolConf ¶
type LightSvrClient ¶
type LightSvrClient struct { ProtocolM protocolmanage.ProtocolManage ProductM productmanage.ProductManage ProductCache dmExport.ProductCacheT DeviceCache dmExport.DeviceCacheT SchemaCache dmExport.DeviceSchemaCacheT DeviceM devicemanage.DeviceManage DeviceInteract deviceinteract.DeviceInteract TimedM timedmanage.TimedManage TimerHandles []func(ctx context.Context, t time.Time) error }
type MqttProtocol ¶
type MqttProtocol struct { *LightProtocol MqttClient *clients.MqttClient DevSubHandle map[string]DevHandle ConnHandle ConnHandle }
func NewMqttProtocol ¶
func NewMqttProtocol(c conf.EventConf, pi *dm.ProtocolInfo, pc *LightProtocolConf, mqttc conf.DevLinkConf) (*MqttProtocol, error)
func (*MqttProtocol) PublishToDev ¶
func (*MqttProtocol) Start ¶
func (m *MqttProtocol) Start() error
func (*MqttProtocol) SubscribeDevConn ¶
func (m *MqttProtocol) SubscribeDevConn(handle ConnHandle) error
func (*MqttProtocol) SubscribeDevMsg ¶
func (m *MqttProtocol) SubscribeDevMsg(topic string, handle DevHandle) error
type SyncDevicesFunc ¶
Click to show internal directories.
Click to hide internal directories.