@@ -744,6 +744,7 @@ static uint8_t handle_string_long_read(struct bt_conn *conn, uint8_t err,
744
744
uint16_t offset = params -> single .offset ;
745
745
uint8_t inst_index = tbs_index (conn , inst );
746
746
const char * received_string ;
747
+ uint16_t str_length ;
747
748
int tbs_err = err ;
748
749
749
750
if ((tbs_err == 0 ) && (data != NULL ) &&
@@ -779,44 +780,38 @@ static uint8_t handle_string_long_read(struct bt_conn *conn, uint8_t err,
779
780
return BT_GATT_ITER_CONTINUE ;
780
781
}
781
782
782
- if (inst -> net_buf .len == 0 ) {
783
- received_string = NULL ;
784
- } else {
785
- uint16_t str_length = inst -> net_buf .len ;
783
+ str_length = inst -> net_buf .len ;
786
784
787
- /* Ensure there is space for string termination */
788
- if (net_buf_simple_tailroom (& inst -> net_buf ) < 1 ) {
789
- LOG_DBG ("Truncating string" );
790
- if (truncatable ) {
791
- /* Truncate */
792
- str_length -- ;
793
- } else {
794
- tbs_err = BT_ATT_ERR_INSUFFICIENT_RESOURCES ;
795
- }
785
+ /* Ensure there is space for string termination */
786
+ if (net_buf_simple_tailroom (& inst -> net_buf ) < 1 ) {
787
+ LOG_DBG ("Truncating string" );
788
+ if (truncatable ) {
789
+ /* Truncate */
790
+ str_length -- ;
791
+ } else {
792
+ tbs_err = BT_ATT_ERR_INSUFFICIENT_RESOURCES ;
796
793
}
794
+ }
797
795
798
- if (tbs_err == 0 ) {
799
- char * str_data ;
796
+ if (tbs_err == 0 ) {
797
+ char * str_data ;
800
798
801
- /* Get a reference to the string buffer */
802
- str_data = net_buf_simple_pull_mem (& inst -> net_buf ,
803
- inst -> net_buf .len );
799
+ /* Get a reference to the string buffer */
800
+ str_data = net_buf_simple_pull_mem (& inst -> net_buf , inst -> net_buf .len );
804
801
805
- /* All strings are UTF-8, truncate properly if needed */
806
- str_data [str_length ] = '\0' ;
807
- received_string = utf8_trunc (str_data );
802
+ /* All strings are UTF-8, truncate properly if needed */
803
+ str_data [str_length ] = '\0' ;
804
+ received_string = utf8_trunc (str_data );
808
805
809
- /* The string might have been truncated */
810
- if (strlen (received_string ) < str_length ) {
811
- LOG_DBG ("Truncating string" );
812
- if (!truncatable ) {
813
- tbs_err =
814
- BT_ATT_ERR_INSUFFICIENT_RESOURCES ;
815
- }
806
+ /* The string might have been truncated */
807
+ if (strlen (received_string ) < str_length ) {
808
+ LOG_DBG ("Truncating string" );
809
+ if (!truncatable ) {
810
+ tbs_err = BT_ATT_ERR_INSUFFICIENT_RESOURCES ;
816
811
}
817
-
818
- LOG_DBG ("%s" , received_string );
819
812
}
813
+
814
+ LOG_DBG ("%s" , received_string );
820
815
}
821
816
822
817
if (tbs_err ) {
@@ -950,7 +945,7 @@ static uint8_t read_uri_list_cb(struct bt_conn *conn, uint8_t err,
950
945
{
951
946
bt_tbs_client_read_string_cb cb = NULL ;
952
947
953
- LOG_DBG ("Read bearer UCI " );
948
+ LOG_DBG ("Read bearer URI list " );
954
949
955
950
if (tbs_client_cbs != NULL && tbs_client_cbs -> uri_list != NULL ) {
956
951
cb = tbs_client_cbs -> uri_list ;
0 commit comments