- fix re-connection after connection loss to broker
- add subscribe call after reconnect - additional config settings for timeout values - add more info/warn outputs - change default log level from "warn" to "info"
This commit is contained in:
@@ -55,7 +55,7 @@ func (p *Pin) State() PinState {
|
||||
}
|
||||
|
||||
func (p *Pin) Command(cmd PinCommand) error {
|
||||
log.Debugf("try to send command %s for pin %s (pin no: %d)", cmd, p.Name, p.Id)
|
||||
log.Infof("send command \"%s\" for pin %s (pin no: %d)", cmd, p.Name, p.Id)
|
||||
if p.Direction != Output {
|
||||
return errors.New("pin is not an output")
|
||||
}
|
||||
@@ -75,9 +75,12 @@ func (p *Pin) Command(cmd PinCommand) error {
|
||||
|
||||
func (p *Pin) Configure() {
|
||||
if p.Direction == Input {
|
||||
log.Infof("configuring pin %s (pin no: %d) as Input", p.Name, p.Id)
|
||||
p.PinHandle.Input()
|
||||
} else if p.Direction == Output {
|
||||
log.Infof("configuring pin %s (pin no: %d) as Output", p.Name, p.Id)
|
||||
p.PinHandle.Output()
|
||||
log.Infof("set initial state \"%s\" for pin %s (pin no: %d)", p.InitialState, p.Name, p.Id)
|
||||
_ = p.Command(p.InitialState)
|
||||
}
|
||||
|
||||
@@ -94,5 +97,9 @@ func (p *Pin) Configure() {
|
||||
}
|
||||
|
||||
func (p *Pin) Changed() bool {
|
||||
return p.PinHandle.EdgeDetected()
|
||||
ret := p.PinHandle.EdgeDetected()
|
||||
if ret {
|
||||
log.Infof("pin %s (pin no: %d) changed state", p.Name, p.Id)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (p *PinControlService) _task() {
|
||||
select {
|
||||
case <-p.timer.C:
|
||||
for pinName, pin := range p.Pins {
|
||||
log.Debug("timer event")
|
||||
//log.Debug("timer event")
|
||||
if pin.Changed() {
|
||||
log.Debugf("detected pin change for pin %s (pin no %d)", pin.Name, pin.Id)
|
||||
if pin.SendChangeEvents && p.OnChangeCallback != nil {
|
||||
|
||||
Reference in New Issue
Block a user