-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT: Basic ble & connect flow #8
base: dev
Are you sure you want to change the base?
Conversation
func centralManager(_: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) { | ||
log.info("Device connect error, name: \(peripheral.name ?? "<NO_NAME>"), error: \(error!.localizedDescription)") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use
func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {}
To handle coming back from background, not sure how you handle this in the other loopkit pump drivers though
return | ||
} | ||
|
||
// TODO: Need to validate if the device name is always MT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, also ensure it's a perfect match, pump boots up in bootloader mode and advertises as "MTBT" you don't want to connect to that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution is to filter bootloader out by device type:
https://github.com/jbr7rr/insuBox/blob/8f217de4df784e86a49ee380fc07968353325e9b/lib/pump/medtrum_bt/comm/PumpScanner.cpp#L68
In that case you don't have to rely on having to correct device name
// Created by Bastiaan Verhaar on 27/02/2025. | ||
// | ||
|
||
class ReadPacket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to consider, In AAPS we had this indeed, In insubox I merged the serialization of the incoming messages in the basePacket as well.
It can make the handling of incoming messages, more straightforward, see:
https://github.com/jbr7rr/insuBox/blob/8f217de4df784e86a49ee380fc07968353325e9b/lib/pump/medtrum_bt/MedtrumBTDevice.cpp#L92
// Created by Bastiaan Verhaar on 26/02/2025. | ||
// | ||
|
||
class WritePacket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unit tests for this thing, It can have nasty surprises ;)
|
||
let commandType: UInt8 = CommandType.SET_TIME_ZONE | ||
|
||
func getRequestBytes() -> Data { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure you do the workaround here for this issue:
nightscout/AndroidAPS#2831
Nice! Good progress! |
Started basic BLE, with read & write, and connection flow.
TODO's:
closes #2