HTS Exported Functions

group HTS_Exported_Functions

Functions

uint8_t hts_add_service(void *p_func)

Add health thermometer service to the Bluetooth Host.

Example usage

void profile_init()
{
    server_init(service_num);
    hts_id = hts_add_service(app_handle_profile_message);
}

Parameters:

p_func[in] Callback when service attribute was read, write or CCCD update.

Return values:
  • 0xFF – Operation failure.

  • others – Service ID assigned by Bluetooth Host.

Returns:

Service ID generated by the Bluetooth Host: T_SERVER_ID.

bool hts_set_parameter(T_HTS_PARAM_TYPE param_type, uint8_t len, void *p_value)

Set a health thermometer service parameter.

Call this function with a health thermometer service parameter type and it will set the health thermometer service parameter. Health thermometer service parameters are defined in T_HTS_PARAM_TYPE. If the “len” field is set to the size of a “uint16_t”, the “p_value” field must point to data with type “uint16_t”.

Example usage

void test(void)
{
    uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT |
                       HTS_FLAG_MEASUREMENT_TYPE_PRESNET_BIT;
    T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;

    hts_measure_time_stamp.seconds += hts_measurement_interval;

    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
                      &hts_measure_time_stamp);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);
}

Parameters:
  • param_type[in] Health thermometer service parameter type: T_HTS_PARAM_TYPE.

  • len[in] Length of data to write.

  • p_value[in] Pointer to data to write. This is dependent on the parameter type and will be cast to the appropriate data type (For example: if data type of param is uint16_t, p_value will be cast to pointer of uint16_t).

Return values:
  • true – Operation success.

  • false – Operation failure.

Returns:

Operation result.

bool hts_measurement_value_indicate(uint8_t conn_id, uint8_t service_id)

Send measurement value indication data. Applications shall call hts_set_parameter to set intermediate temperature value first, and then call this API to send the indication value.

Example usage

void test(void)
{
    uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT |
                       HTS_FLAG_MEASUREMENT_TYPE_PRESNET_BIT;
    T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;

    hts_measure_time_stamp.seconds += hts_measurement_interval;

    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
                      &hts_measure_time_stamp);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);

    bool ret = hts_measurement_value_indicate(conn_id, hts_id);
}

Parameters:
  • conn_id[in] Connection ID.

  • service_id[in] Service ID.

Return values:
  • true – Operation success.

  • false – Operation failure.

Returns:

Operation result.

bool hts_intermediate_temperature_value_notify(uint8_t conn_id, uint8_t service_id)

Send intermediate temperature notification data. Applications shall call hts_set_parameter to set intermediate temperature value first, and then call this API to send the notification value.

Example usage

void test(void)
{
    uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT
                       | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT
                       | HTS_FLAG_MEASUREMENT_TYPE_PRESNET_BIT;
    T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;

    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
                      &hts_measure_time_stamp);
    hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);

    bool ret = hts_intermediate_temperature_value_notify(conn_id, hts_id);
}

Parameters:
  • conn_id[in] Connection ID.

  • service_id[in] Service ID.

Return values:
  • true – Operation success.

  • false – Operation failure.

Returns:

Operation result.

bool hts_measurement_interval_notify(uint8_t conn_id, uint8_t service_id, uint16_t seconds)

Send measurement interval notification data.

Example usage

void test(void)
{
    bool ret = hts_measurement_interval_notify(conn_id, hts_id, interval);
}

Parameters:
  • conn_id[in] Connection ID.

  • service_id[in] Service ID.

  • seconds[in] Measurement interval.

Return values:
  • true – Operation success.

  • false – Operation failure.

Returns:

Operation result.