Closed PietroGranati closed 1 year ago
Are those even available on IOS? Can you check the documentation? The MFi and ExternalAccessory on IOS has limited functionality and those might not even be available.
I have some notes saying that I need to see if the CoreBluetooth
library can be used for those types of things.
The in the official documentation they're avaiable for both
I'll investigate more
haha "official" of this library? Could be wrong - you're trusting me a whole bunch.
Looking at the IOS code, there is only registration for:
Looking at the available notifications: https://developer.apple.com/documentation/foundation/nsnotification/name there are only two that are used:
there are a couple others that maybe might work for Enabled/Disabled/State Change:
No idea really.
Feel free to play around with it and add those registered notifications to:
/**
Register with the NotificationCenter and add all appropriate Observers. Currently the available
notification types are:
- .EAAccessoryDidConnect = BTEvent.BLUETOOTH_CONNECTED
- .EAAccessoryDidDisconnect = BTEvent.BLUETOOTH_DISCONNECTED
using the appropriate BTEvent type(s)
*/
private func registerForLocalNotifications() {
eaManager.registerForLocalNotifications()
notificationCenter.addObserver(self,
selector: #selector(accessoryDidConnect),
name: .EAAccessoryDidConnect,
object: nil)
notificationCenter.addObserver(self,
selector: #selector(accessoryDidDisconnect),
name: .EAAccessoryDidDisconnect,
object: nil)
}
And throw in a pull request, i'd be happy to accept it if you say it works.
Ahah yes of this library, it's a great module however! I'm not so good at IOS coding but I'll give it a try in these days.
Thank you!
I'm not so good at IOS coding but I'll give it a try in these days.
Join the club!!
I would play around with something like:
private func registerForLocalNotifications() {
eaManager.registerForLocalNotifications()
notificationCenter.addObserver(self,
selector: #selector(accessoryDidConnect),
name: .EAAccessoryDidConnect,
object: nil)
notificationCenter.addObserver(self,
selector: #selector(accessoryDidDisconnect),
name: .EAAccessoryDidDisconnect,
object: nil)
notificationCenter.addObserver(self,
selector: #selector(bluetoothPoweredOn),
name: .IOBluetoothHostControllerPoweredOff,
object: nil)
}
@objc
func bluetoothPoweredOn(_ notification:Notification) {
sendEvent(EventType.BLUETOOTH_ENABLED.name,
body: (simulate whatever Android sends now)
sendEvent(EventType.STATE_CHANGED.name,
body: (simulate whatever Android sends now)
}
Mobile Device Environment
Application Environment
Describe the bug I cannt made work the events "onStateChanged" "onBluetoothEnabled" "onBluetoothDisabled", the onDevice connect works perfectly instead anche i cannot figure out what is wrong
To Reproduce