Skip to content

The EnableNotifications callback in Mac system uses coroutine. Can the coroutine call be removed? #402

@DustScribe

Description

@DustScribe

When using the Mac platform, if you use EnableNotifications to listen for changes in characteristic values ​​when receiving data, and if the data sent by the Bluetooth device is split into multiple packets, the DidUpdateValueForCharacteristic method uses a coroutine to call the callback function, which will cause the data packet reception order and the sending order to be inconsistent, resulting in the data after the packet splicing being inconsistent with the original data. Can I remove the coroutine callback and implement it myself in the program?

func (pd *peripheralDelegate) DidUpdateValueForCharacteristic(prph cbgo.Peripheral, chr cbgo.Characteristic, err error) {
	uuid, _ := ParseUUID(chr.UUID().String())
	svcuuid, _ := ParseUUID(chr.Service().UUID().String())

	if svc, ok := pd.d.services[svcuuid]; ok {
		for _, char := range svc.characteristics {

			if char.characteristic == chr && uuid == char.UUID() { // compare pointers
				if err == nil && char.callback != nil {
					go char.callback(chr.Value())
				}

				if char.readChan != nil {
					char.readChan <- err
				}
			}

		}

	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions