LNS Exported Functions

group LNS_Exported_Functions

Functions

uint8_t lns_add_service(void *p_func)

Add location and navigation service to the Bluetooth Host.

Example usage

void profile_init()
{
 server_init(service_num);
 lns_id = lns_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 lns_set_parameter(T_LNS_PARAM_TYPE param_type, uint8_t len, void *p_value)

Set a Location and Navigation service parameter.

This function can be called with a LNS parameter type T_LNS_PARAM_TYPE and it will set the LNS parameter. The 'p_value' field must point to an appropriate data type that meets the requirements for the corresponding parameter type. (For example, if required data length for parameter type is 1 octets, p_value should be cast to a pointer of uint8_t.)

Example usage

void test(void)
{
    T_LOCATION_AND_SPEED_VALUE_FLAG flag;
    flag.instantaneous_speed_present = 1;
    flag.total_distance_present = 1;
    flag.location_present = 1;
    flag.elevation_present = 1;
    flag.heading_present = 1;
    flag.rolling_time_present = 1;
    flag.utc_time_present = 1;
    flag.position_status = 1;
    flag.speed_and_distance_format = 1;
    flag.elevation_source = 1;
    flag.heading_source = 1;
    flag.rfu = 0;

    bool ret = lns_set_parameter(LNS_LAS_PARAM_INC_FLAG, 2, &flag);
}
Parameters:
  • param_type -- [in] Location and Navigation service parameter type: T_LNS_PARAM_TYPE.

  • len -- [in] Length of data to write.

  • p_value -- [in] Pointer to data to write.

Return values:
  • true -- Operation success.

  • false -- Operation failure.

Returns:

Operation result.

bool lns_location_and_speed_value_notify(uint8_t conn_id, T_SERVER_ID service_id)

Send location and speed value notification data. Applications shall call lns_set_parameter with param_type LNS_LAS_PARAM_INC_FLAG to set location and speed value first, and then call this API to send the notification value.

Example usage

void test(void)
{
    bool op_result = lns_location_and_speed_value_notify(conn_id, lns_id);
}
Parameters:
  • conn_id -- [in] Connection ID.

  • service_id -- [in] Service ID.

Return values:
  • true -- Operation success.

  • false -- Operation failure.

Returns:

Operation result.

bool lns_navigation_value_notify(uint8_t conn_id, T_SERVER_ID service_id)

Send navigation value notification data. Applications shall call lns_set_parameter with param_type LNS_NAVIGATION_PARAM_INC_FLAG to set navigation value first, and then call this API to send the notification value.

Example usage

void test(void)
{
    bool op_result = lns_navigation_value_notify(conn_id, lns_id);
}
Parameters:
  • conn_id -- [in] Connection ID.

  • service_id -- [in] Service ID.

Return values:
  • true -- Operation success.

  • false -- Operation failure.

Returns:

Operation result.