If you need help to write code, we do offer services: www.mbientlab.com/services.
Otherwise maybe you have a developer friend or colleague that can help you?
let battery_signal = mbl_mw_settings_get_battery_state_data_signal(DiagnosticVC.deviceBoard.board)
mbl_mw_datasignal_subscribe(battery_signal!, nil) { (context, data) in
let state = MblMwBatteryState()
print(state.charge)
}
mbl_mw_datasignal_read(battery_signal)
@sanjeev said:
let battery_signal = mbl_mw_settings_get_battery_state_data_signal(DiagnosticVC.deviceBoard.board)
mbl_mw_datasignal_subscribe(battery_signal!, nil) { (context, data) in
let state = MblMwBatteryState()
print(state.charge)
}
mbl_mw_datasignal_read(battery_signal)
guard let board = device?.board else {return}
guard mbl_mw_metawearboard_lookup_module(board, MBL_MW_MODULE_SETTINGS) != MODULE_TYPE_NA else { return }
let signal = mbl_mw_settings_get_battery_state_data_signal(board)
mbl_mw_datasignal_subscribe(signal, bridge(obj: self)) {(context, data) in
let _self: viewController = bridge(ptr: context!)
let state = data!.pointee.valueAs() as MblMwBatteryState
print("Battery charge : \(state.charge)%")
/*
// if you want to pass this value (state.charge) to other swift function
DispatchQueue.main.async {
_self.updateBatteryChargeLabel(Int(state.charge))
}
*/
}
mbl_mw_datasignal_read(signal)
Comments
https://mbientlab.com/cppdocs/0/settings.html#battery-state
Hi Eric,
Thanks for that. Is there a Swift equivalent to the C++ code ?
pls share the swift code
@gowtham, you need to write the swift code yourself.
can you pls share with me please in urgent
If you need help to write code, we do offer services: www.mbientlab.com/services.
Otherwise maybe you have a developer friend or colleague that can help you?
can you please share code how to check battery level in swift
let battery_signal = mbl_mw_settings_get_battery_state_data_signal(DiagnosticVC.deviceBoard.board)
I used this code
Thanks sanjeev