battery_service_client_connect() function
Connect to Battery Services of remote device. The client will try to register for notifications. If notifications are not supported by remote Battery Service, the client will poll battery level If poll_interval_ms is 0, polling is disabled, and only notifications will be received. In either case, the battery level is received via GATTSERVICE_SUBEVENT_BATTERY_SERVICE_LEVEL event. The battery level is reported as percentage, i.e. 100 = full and it is valid if the ATTT status is equal to ATT_ERROR_SUCCESS, see ATT errors (see bluetooth.h) for other values. For manual polling, see battery_service_client_read_battery_level below. Event GATTSERVICE_SUBEVENT_BATTERY_SERVICE_CONNECTED is emitted with status ERROR_CODE_SUCCESS on success, otherwise GATT_CLIENT_IN_WRONG_STATE, ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no battery service is found, or ATT errors (see bluetooth.h). This event event also returns number of battery instances found on remote server, as well as poll bitmap that indicates which indexes of services require polling, i.e. they do not support notification on battery level change,
Arguments
poll_interval_ms
or 0 to disable polling
Return value
status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_COMMAND_DISALLOWED if there is already a client associated with con_handle, or BTSTACK_MEMORY_ALLOC_FAILED