firmata: return connect errors to client

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-05-11 21:15:00 +02:00
parent efee462c95
commit c057909011
1 changed files with 10 additions and 6 deletions

View File

@ -158,26 +158,27 @@ func (b *Client) Connect(conn io.ReadWriteCloser) (err error) {
return ErrConnected
}
var connectErr error
b.connection = conn
b.Reset()
b.Once(b.Event("ProtocolVersion"), func(data interface{}) {
err := b.FirmwareQuery()
if err != nil {
connectErr = b.FirmwareQuery()
if connectErr != nil {
b.setConnecting(false)
}
})
b.Once(b.Event("FirmwareQuery"), func(data interface{}) {
err := b.CapabilitiesQuery()
if err != nil {
connectErr = b.CapabilitiesQuery()
if connectErr != nil {
b.setConnecting(false)
}
})
b.Once(b.Event("CapabilityQuery"), func(data interface{}) {
err := b.AnalogMappingQuery()
if err != nil {
connectErr = b.AnalogMappingQuery()
if connectErr != nil {
b.setConnecting(false)
}
})
@ -214,6 +215,9 @@ func (b *Client) Connect(conn io.ReadWriteCloser) (err error) {
return
default:
if connectErr != nil {
return connectErr
}
break
}
}