Battery level

In xCode for iOS, an older example to read the battery level is

    device.readBatteryLifeAsync().success { result in
        self.batteryLevelLabel.text = result.stringValue
    }

I cannot seem to find this function in the latest MetaWear API.

Please advise.

Comments

  • 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.

  • @Laura said:
    @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)

        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)
    

    I used this code

Sign In or Register to comment.