func connFind()

in nmxact/nmble/ble_act.go [749:790]


func connFind(x *BleXport, bl *Listener, r *BleConnFindReq) (
	BleConnDesc, error) {

	const rspType = MSG_TYPE_CONN_FIND

	j, err := json.Marshal(r)
	if err != nil {
		return BleConnDesc{}, err
	}

	if err := x.Tx(j); err != nil {
		return BleConnDesc{}, err
	}

	bhdTmoChan := bl.AfterTimeout(x.RspTimeout())
	for {
		select {
		case err := <-bl.ErrChan:
			return BleConnDesc{}, err

		case bm := <-bl.MsgChan:
			switch msg := bm.(type) {
			case *BleConnFindRsp:
				bl.Acked = true
				if msg.Status != 0 {
					return BleConnDesc{},
						StatusError(MSG_OP_RSP, rspType, msg.Status)
				}

				return BleDescFromConnFindRsp(msg), nil

			default:
			}

		case _, ok := <-bhdTmoChan:
			if ok {
				x.Restart("Blehostd timeout: " + MsgTypeToString(rspType))
			}
			bhdTmoChan = nil
		}
	}
}