Generalize socket cancellation and update API accordingly

This commit is contained in:
2021-10-23 18:03:17 -07:00
parent ef4bad94b5
commit e198b769f9
9 changed files with 211 additions and 76 deletions
+13 -2
View File
@@ -31,7 +31,18 @@ func (c *Client) FirmwareUpgrade(upgType UpgradeType, files ...string) (<-chan D
return nil, err
}
c.dfuProgressCh = make(chan DFUProgress, 5)
c.dfuProgressCh = make(chan types.Response, 5)
return c.dfuProgressCh, nil
out := make(chan DFUProgress, 5)
go func() {
for res := range c.dfuProgressCh {
progress, err := decodeDFUProgress(res.Value)
if err != nil {
continue
}
out <- progress
}
}()
return out, nil
}