123456789101112131415161718192021222324252627282930313233343536 |
- package gate_command
- import (
- dbmodel "property-device/model"
- "property-device/utils/gate_utils"
- )
- type Commander interface {
- Open() error
- Reboot() error
- Command() bool
- }
- func NewCommander(gateInfo *dbmodel.TGate) Commander {
- switch gateInfo.Protocol {
- case gate_utils.GateProtocolYufanHttpV1:
- byIp := false
- if gate_utils.CheckYufanIp(gateInfo.Ip, gateInfo.Port, gateInfo.Password) {
- byIp = true
- }
- return &YufanHttpv1Commander{
- GateInfo: gateInfo,
- ByIp: byIp,
- }
- case gate_utils.GateProtocolSaiboMqttV1:
- return &SaiboMqttv1Commander{
- GateInfo: gateInfo,
- }
- case gate_utils.GateProtocolSaiboHttpV1:
- return &SaiboHttpv1Commander{
- GateInfo: gateInfo,
- }
- }
- return nil
- }
|