mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-15 23:42:52 +00:00
gatt-service/bas_server: add skeleton setters
This commit is contained in:
parent
e16068db65
commit
e24f316c1b
@ -203,7 +203,7 @@ static uint8_t bas_serialize_characteristic(battery_service_v1_t * service, bas_
|
||||
break;
|
||||
|
||||
case BAS_CHARACTERISTIC_INDEX_BATTERY_CRITCAL_STATUS:
|
||||
event[pos++] = service->battery_critcal_status_flags;
|
||||
event[pos++] = service->critcal_status_flags;
|
||||
break;
|
||||
|
||||
case BAS_CHARACTERISTIC_INDEX_BATTERY_ENERGY_STATUS:
|
||||
@ -614,17 +614,104 @@ uint8_t battery_service_v1_server_set_battery_level_status(battery_service_v1_t
|
||||
return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
}
|
||||
|
||||
if ( (battery_level_status->flags & BATTERY_LEVEL_STATUS_BITMASK_ADDITIONAL_STATUS_PRESENT) > 0u){
|
||||
if ((battery_level_status->flags & BATTERY_LEVEL_STATUS_BITMASK_ADDITIONAL_STATUS_PRESENT) > 0u){
|
||||
if (battery_level_status->additional_status_flags >= BATTERY_LEVEL_ADDITIONAL_STATUS_BITMASK_RFU){
|
||||
return ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
service->level_status = battery_level_status;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_LEVEL_STATUS);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_estimated_service_date_days(battery_service_v1_t * service, uint32_t estimated_service_date_days){
|
||||
btstack_assert(service != NULL);
|
||||
|
||||
service->estimated_service_date_days = estimated_service_date_days;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_ESTIMATED_SERVICE_DATE);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_critcal_status_flags(battery_service_v1_t * service, uint8_t critcal_status_flags){
|
||||
btstack_assert(service != NULL);
|
||||
|
||||
service->critcal_status_flags = critcal_status_flags;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_CRITCAL_STATUS);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_energy_status(battery_service_v1_t * service, const battery_energy_status_t * energy_status){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(energy_status != NULL);
|
||||
|
||||
service->energy_status = energy_status;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_ENERGY_STATUS);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_time_status(battery_service_v1_t * service, const battery_time_status_t * time_status){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(time_status != NULL);
|
||||
|
||||
service->time_status = time_status;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_TIME_STATUS);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_health_status(battery_service_v1_t * service, const battery_health_status_t * health_status){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(health_status != NULL);
|
||||
|
||||
service->health_status = health_status;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_HEALTH_STATUS);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_health_information(battery_service_v1_t * service, const battery_health_information_t * health_information){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(health_information != NULL);
|
||||
|
||||
service->health_information = health_information;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_HEALTH_INFORMATION);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_information(battery_service_v1_t * service, const battery_information_t * information){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(information != NULL);
|
||||
|
||||
service->information = information;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_BATTERY_INFORMATION);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_manufacturer_name(battery_service_v1_t * service, const char * manufacturer_name){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(manufacturer_name != NULL);
|
||||
|
||||
service->manufacturer_name = manufacturer_name;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_MANUFACTURER_NAME_STRING);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_model_number(battery_service_v1_t * service, const char * model_number){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(model_number != NULL);
|
||||
|
||||
service->model_number = model_number;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_MODEL_NUMBER_STRING);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t battery_service_v1_server_set_serial_number(battery_service_v1_t * service, const char * serial_number){
|
||||
btstack_assert(service != NULL);
|
||||
btstack_assert(serial_number != NULL);
|
||||
|
||||
service->serial_number = serial_number;
|
||||
bas_server_set_callback(service, BAS_CHARACTERISTIC_INDEX_SERIAL_NUMBER_STRING);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void battery_service_v1_server_deregister(battery_service_v1_t *service){
|
||||
btstack_linked_list_remove(&battery_services, (btstack_linked_item_t * )service);
|
||||
|
@ -237,7 +237,7 @@ typedef struct battery_service_v1 {
|
||||
uint32_t estimated_service_date_days;
|
||||
|
||||
// ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_CRITCAL_STATUS
|
||||
uint8_t battery_critcal_status_flags;
|
||||
uint8_t critcal_status_flags;
|
||||
|
||||
// ORG_BLUETOOTH_CHARACTERISTIC_BATTERY_ENERGY_STATUS
|
||||
const battery_energy_status_t * energy_status;
|
||||
@ -285,7 +285,7 @@ void battery_service_v1_server_deregister(battery_service_v1_t * service);
|
||||
* @param battery_level in range 0-100
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_battery_level(battery_service_v1_t * service, uint8_t battery_level);
|
||||
uint8_t battery_service_v1_server_set_battery_level(battery_service_v1_t * service,uint8_t battery_level);
|
||||
|
||||
/**
|
||||
* @brief Update battery level status
|
||||
@ -296,6 +296,95 @@ uint8_t battery_service_v1_server_set_battery_level(battery_service_v1_t * servi
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_battery_level_status(battery_service_v1_t * service, const battery_level_status_t * battery_level_status);
|
||||
|
||||
/**
|
||||
* @brief Update battery estimated service date
|
||||
* @note Triggers notification or indication if subscribed
|
||||
* @param service
|
||||
* @param estimated_service_date_days
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_estimated_service_date_days(battery_service_v1_t * service, uint32_t estimated_service_date_days);
|
||||
|
||||
/**
|
||||
* @brief Update battery critcal status flags
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param critcal_status_flags
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_critcal_status_flags(battery_service_v1_t * service, uint8_t critcal_status_flags);
|
||||
|
||||
/**
|
||||
* @brief Update battery energy status
|
||||
* @note Triggers notification or indication if subscribed
|
||||
* @param service
|
||||
* @param energy_status
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_energy_status(battery_service_v1_t * service, const battery_energy_status_t * energy_status);
|
||||
|
||||
/**
|
||||
* @brief Update battery time status
|
||||
* @note Triggers notification or indication if subscribed
|
||||
* @param service
|
||||
* @param time_status
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_time_status(battery_service_v1_t * service, const battery_time_status_t * time_status);
|
||||
|
||||
/**
|
||||
* @brief Update battery health status
|
||||
* @note Triggers notification or indication if subscribed
|
||||
* @param service
|
||||
* @param health_status
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_health_status(battery_service_v1_t * service, const battery_health_status_t * health_status);
|
||||
|
||||
/**
|
||||
* @brief Update battery health information
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param health_information
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_health_information(battery_service_v1_t * service, const battery_health_information_t * health_information);
|
||||
|
||||
/**
|
||||
* @brief Update battery information
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param information
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_information(battery_service_v1_t * service, const battery_information_t * information);
|
||||
|
||||
/**
|
||||
* @brief Update manufacturer name
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param manufacturer_name
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_manufacturer_name(battery_service_v1_t * service, const char * manufacturer_name);
|
||||
|
||||
/**
|
||||
* @brief Update model_number
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param model number
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_model_number(battery_service_v1_t * service, const char * model_number);
|
||||
|
||||
/**
|
||||
* @brief Update serial_number
|
||||
* @note Triggers indication if subscribed
|
||||
* @param service
|
||||
* @param serial number
|
||||
* @return ERROR_CODE_SUCCESS if value is valid, otherwise ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE
|
||||
*/
|
||||
uint8_t battery_service_v1_server_set_serial_number(battery_service_v1_t * service, const char * serial_number);
|
||||
|
||||
void battery_service_v1_server_deinit(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user