Community Translation - Read Bluetooth® service characteristic using its UUID – KBA235669

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KeTa_1341526
Level 5
Level 5
Distributor - TED (Japan)
10 likes given 10 likes received 5 likes given

Dear supporter,

 

I want to translate the following KBA, Please confirm to my work.

 

Read Bluetooth® service characteristic using its UUID – KBA235669

 

Thanks,

0 Likes
1 Solution
KeTa_1341526
Level 5
Level 5
Distributor - TED (Japan)
10 likes given 10 likes received 5 likes given

Hi Bindu san,

The following shows the translated version in Japanese for targeted KBA.

Please conform and double check.

----------------------------------------------------------------------------------------

UUIDを使用してBluetooth® service characteristic を読み取る – KBA235669

バージョン: **

注: この記事は、Bluetooth® ホストスタックライブラリにのみ適用されます。

 

1. UUIDを使用してBluetooth® characteristic データを読み取る

UUIDまたは「by type」を使用してデータを読み取るには、wiced_bt_gatt_client_send_read_by_type APIを使用してread-by-type リクエストを送信します。詳細については、最新の Bluetooth® specification vol 3 (Host), part F: Attribute protocol, section 3.4.4.1 を参照してください。

KeTa_1341526_0-1657100947252.png

            図1:Bluetooth® characteristic UUID

 

read-by-type リクエストで温度データを送信するために要求される ble-ess に基づいた次の例を検討してください。

コードリスト1

wiced_bt_uuid_t uuid;
char *f;    //to hold the received buffer, only required if packet size exceeds the MTU
uuid.len = LEN_UUID_16;
uuid.uu.uuid16 = 0x2901; //enter UUID for the corresponding entity
wiced_bt_gatt_client_send_read_by_type(connection_id, 0x1, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE);

 

read-by-type リクエストが送信されると、応答はピアサーバーによって返送され、GATTイベントハンドラのGATT_OPERATION_CPLT_EVTで受信されます。

例:

コードリスト2

uint16_t len = 0;
uint8_t* ptr = NULL;
wiced_bt_gatt_event_data_t *p_event_data;
if (p_event_data->operation_complete.status == WICED_BT_GATT_SUCCESS)
{
      if(p_event_data->operation_complete.op == GATTC_OPTYPE_READ_HANDLE)
{
ptr = p_event_data->operation_complete.response_data.att_value.p_data;                   len = p_event_data->operation_complete.response_data.att_value.len;
                   printf(" handle read, len %d \n", len);
                   for(uint8_t i =0;i<len;i++)
                   {
                         printf("%c\n",ptr[i] );
                   }
      }
}

 

注:スタックは、read-by-type リクエストを送信した場合でも、GATTC_OPTYPE_READ_HANDLEイベントでデータが読み取られるように開発されています。

 

2. 同じUUIDで複数のハンドルを取得する

注: 2つ以上のハンドルが同じUUIDを持っている場合、最も低いハンドルを持つハンドルのみを読み取ることができます。

Environmental Sensing service における温度および圧力特性のユーザー記述子の例を考えてみましょう。

KeTa_1341526_1-1657101954900.png

図2:ユーザー記述子

図2は、両方が同じUUID (2901) を持っていることを示しています。ここで、温度特性にハンドル「D」のユーザー記述子があり、圧力特性にハンドル「14」のユーザー記述子がある場合、温度ユーザー記述子 ハンドルのみが読み取られます。

 

2.1 方法1

これは、ピアデバイスがread-by-type リクエストごとに要求されたUUIDを持つハンドルを1つだけ送信する場合に適用されます。

次に低いハンドルを取得するには、別のread-by-type リクエストを送信し、read-by-type APIの開始ハンドルを記述子読み取りのハンドルより1つ多く更新します。

例:

コードリスト3

wiced_bt_gatt_client_send_read_by_type(connection_id, 0x1, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE); //for temperature descriptor

wiced_bt_gatt_client_send_read_by_type(connection_id, 0x000B, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE); //for pressure descriptor as 0x000B is 1+0x000A.

 

2.2 方法2

これは、ピアデバイスがread-by-type リクエストごとに要求されたUUIDを持つすべてのハンドルを送信する場合に適用されます。

この場合、単にread-by-type リクエストを送信する以外に、クライアント側で追加の実装を行う必要はありません。サーバー側でこのメソッドがどのように処理されるかについては、このコード例の「app_gatt_read_by_type_handler」を参照してください。

pending_eventsフラグは、関連するリクエストの残りのイベントの数を示します。

例:

KeTa_1341526_2-1657103186205.png

                    サーバー (COM9)                                           クライアント (COM4)

温度記述子(サンプル値としてtest1)を読み取ると、pending_eventsフラグが「1」に設定されます。これは、UUIDとread-by-type リクエストの開始および終了のハンドルパラメーターが一致する別のイベント (圧力記述子) があることを示します。pending_eventsフラグの値を確認するには、GATT_OPERATION_CPLT_EVTで次のコマンドを使用します。

コードリスト4

uint8_t pending;
pending = p_event_data->operation_complete.pending_events;
printf("number of pending events: %d\n",pending);

したがって、フラグは、同じ要求に対応するサーバーから読み取るイベントが他にあるかどうかを確認する為にを使用できます。

 

Labels:  Other

Tags:  ble  bt  observer  peripherals  stack  wifi bt combo

View solution in original post

0 Likes
3 Replies
IFX_Publisher2
Community Manager
Community Manager
Community Manager
1000 replies posted First like given 750 replies posted

Hi,

Confirm to work on this KBA.

Thanks,
Bindu.

0 Likes
KeTa_1341526
Level 5
Level 5
Distributor - TED (Japan)
10 likes given 10 likes received 5 likes given

Hi Bindu san,

The following shows the translated version in Japanese for targeted KBA.

Please conform and double check.

----------------------------------------------------------------------------------------

UUIDを使用してBluetooth® service characteristic を読み取る – KBA235669

バージョン: **

注: この記事は、Bluetooth® ホストスタックライブラリにのみ適用されます。

 

1. UUIDを使用してBluetooth® characteristic データを読み取る

UUIDまたは「by type」を使用してデータを読み取るには、wiced_bt_gatt_client_send_read_by_type APIを使用してread-by-type リクエストを送信します。詳細については、最新の Bluetooth® specification vol 3 (Host), part F: Attribute protocol, section 3.4.4.1 を参照してください。

KeTa_1341526_0-1657100947252.png

            図1:Bluetooth® characteristic UUID

 

read-by-type リクエストで温度データを送信するために要求される ble-ess に基づいた次の例を検討してください。

コードリスト1

wiced_bt_uuid_t uuid;
char *f;    //to hold the received buffer, only required if packet size exceeds the MTU
uuid.len = LEN_UUID_16;
uuid.uu.uuid16 = 0x2901; //enter UUID for the corresponding entity
wiced_bt_gatt_client_send_read_by_type(connection_id, 0x1, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE);

 

read-by-type リクエストが送信されると、応答はピアサーバーによって返送され、GATTイベントハンドラのGATT_OPERATION_CPLT_EVTで受信されます。

例:

コードリスト2

uint16_t len = 0;
uint8_t* ptr = NULL;
wiced_bt_gatt_event_data_t *p_event_data;
if (p_event_data->operation_complete.status == WICED_BT_GATT_SUCCESS)
{
      if(p_event_data->operation_complete.op == GATTC_OPTYPE_READ_HANDLE)
{
ptr = p_event_data->operation_complete.response_data.att_value.p_data;                   len = p_event_data->operation_complete.response_data.att_value.len;
                   printf(" handle read, len %d \n", len);
                   for(uint8_t i =0;i<len;i++)
                   {
                         printf("%c\n",ptr[i] );
                   }
      }
}

 

注:スタックは、read-by-type リクエストを送信した場合でも、GATTC_OPTYPE_READ_HANDLEイベントでデータが読み取られるように開発されています。

 

2. 同じUUIDで複数のハンドルを取得する

注: 2つ以上のハンドルが同じUUIDを持っている場合、最も低いハンドルを持つハンドルのみを読み取ることができます。

Environmental Sensing service における温度および圧力特性のユーザー記述子の例を考えてみましょう。

KeTa_1341526_1-1657101954900.png

図2:ユーザー記述子

図2は、両方が同じUUID (2901) を持っていることを示しています。ここで、温度特性にハンドル「D」のユーザー記述子があり、圧力特性にハンドル「14」のユーザー記述子がある場合、温度ユーザー記述子 ハンドルのみが読み取られます。

 

2.1 方法1

これは、ピアデバイスがread-by-type リクエストごとに要求されたUUIDを持つハンドルを1つだけ送信する場合に適用されます。

次に低いハンドルを取得するには、別のread-by-type リクエストを送信し、read-by-type APIの開始ハンドルを記述子読み取りのハンドルより1つ多く更新します。

例:

コードリスト3

wiced_bt_gatt_client_send_read_by_type(connection_id, 0x1, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE); //for temperature descriptor

wiced_bt_gatt_client_send_read_by_type(connection_id, 0x000B, 0xFFFF, &uuid,(uint8_t *)&f,sizeof(f), GATT_AUTH_REQ_NONE); //for pressure descriptor as 0x000B is 1+0x000A.

 

2.2 方法2

これは、ピアデバイスがread-by-type リクエストごとに要求されたUUIDを持つすべてのハンドルを送信する場合に適用されます。

この場合、単にread-by-type リクエストを送信する以外に、クライアント側で追加の実装を行う必要はありません。サーバー側でこのメソッドがどのように処理されるかについては、このコード例の「app_gatt_read_by_type_handler」を参照してください。

pending_eventsフラグは、関連するリクエストの残りのイベントの数を示します。

例:

KeTa_1341526_2-1657103186205.png

                    サーバー (COM9)                                           クライアント (COM4)

温度記述子(サンプル値としてtest1)を読み取ると、pending_eventsフラグが「1」に設定されます。これは、UUIDとread-by-type リクエストの開始および終了のハンドルパラメーターが一致する別のイベント (圧力記述子) があることを示します。pending_eventsフラグの値を確認するには、GATT_OPERATION_CPLT_EVTで次のコマンドを使用します。

コードリスト4

uint8_t pending;
pending = p_event_data->operation_complete.pending_events;
printf("number of pending events: %d\n",pending);

したがって、フラグは、同じ要求に対応するサーバーから読み取るイベントが他にあるかどうかを確認する為にを使用できます。

 

Labels:  Other

Tags:  ble  bt  observer  peripherals  stack  wifi bt combo

0 Likes
IFX_Publisher2
Community Manager
Community Manager
Community Manager
1000 replies posted First like given 750 replies posted

Hi,

Confirmed to receive this KBA.

Thank you for your contribution.

Thanks,
Bindu

0 Likes