in nmxact/nmble/ble_xport.go [339:394]
func (bx *BleXport) startEvent() error {
fail := func(err error) error {
bx.shutdown(nmxutil.NewXportError(err.Error()))
return err
}
// Make sure we don't think we are still in sync with the controller. If
// we fail early, we don't want to try sending a reset command.
bx.syncer.Stop()
if err := bx.startUnixChild(); err != nil {
return fail(err)
}
// Listen for errors and data from the blehostd process.
bx.wg.Add(1)
go func() {
defer bx.wg.Done()
for {
select {
case err, ok := <-bx.client.ErrChild:
if ok {
bx.enqueueShutdown(nmxutil.NewXportError(
"BLE transport error: " + err.Error()))
}
case buf := <-bx.client.FromChild:
if len(buf) != 0 {
log.Debugf("Receive from blehostd:\n%s", hex.Dump(buf))
bx.d.Dispatch(buf)
}
case <-bx.stopChan:
return
}
}
}()
// Listen for sync and reset; blocks until initial sync.
if err := bx.startSyncer(); err != nil {
return fail(err)
}
// Set the random address.
if err := bx.setAddr(); err != nil {
return fail(err)
}
// Set the preferred ATT MTU in the host.
if err := SetPreferredMtuXact(bx, bx.cfg.PreferredMtu); err != nil {
return fail(err)
}
return nil
}