제공업체는 계정 데이터 외에도 추가 필드를 포함해야 합니다.
배터리 값을 지정합니다. 패킷에는 다음이 포함되어야 합니다.
옥텟
데이터 유형
설명
값
필수 여부
0
uint8
플래그
0x00 (향후 사용을 위해 예약된 모든 비트)
필수
1~초
계정 키 데이터
필수
초 + 1
uint8
배터리 잔량 길이 및 유형 0bLLLLTTTT
L = 배터리 값의 수
T = 유형
0억 달러
길이 = 0b0011 = 배터리 값 3개
type = 0b0011 (UI 표시 표시) 또는 0b0100 (UI 표시 숨기기)
선택사항
s + 2, s + 3, s + 4
uint8
배터리 값 0bSVVVVVVV
S = 상태 (충전 중 또는 충전 중 아님)
V = 값
배터리 값은 왼쪽 이어폰 (s + 2), 오른쪽 이어폰 (s + 3), 케이스 (s + 4)로 정렬해야 합니다.
0bSVVVVVVV
status = 0b1 (충전 중) 또는 0b0 (충전 중)
값 = 배터리 잔량(0~100퍼센트), 0bS1111111(알 수 없는 경우)
선택사항
조작을 방지하기 위해 위의 계정 키 데이터가 약간 설정되어야 합니다.
배터리 값이 포함될 때 배터리 정보를 포함하도록 수정됨
사용할 수 없습니다. 일반적으로 계정 키를 만들 때
필터에서 사용할 수 있는 경우 계정 ID와 계정 ID를 결합하여 값 V가 생성됩니다.
솔트를 넣으세요. 대신 배터리 정보도 광고되는 경우
값 V는 다음과 같이 구성되어야 합니다.
V 값을 생성합니다. 각 항목의 의미는 다음과 같습니다.
<ph type="x-smartling-placeholder"></ph>
나머지 바이트는 배터리 정보 (s + 1 ~ s + 4)입니다.
(위 표의 길이 및 유형 바이트 포함).
위의 배터리 길이 및 유형 필드에서 언급한 것처럼 유형은 다음 중 하나일 수 있습니다.
0b0011 또는 0b0100
0b0011 - 제공자가 탐색자가
배터리 값의 UI
0b0100 - 제공자가 탐색자가 표시를 숨기도록 할 때 사용
이(가) 이미 표시되고 있습니다.
한 가지 일반적인 사용 사례는 케이스가 열린 상태에서 0b0011를 사용하는 것입니다.
이어폰을 케이스에서 제거했거나 다시 닫으면 0b0100 상태가 됩니다.
//The sample code demonstrates that the headset only reports the battery level.#define FASTPAIR_ACCOUNT_KEY_SIZE 16// In the sample code, the size of salt is 2 bytes.#define SALT_SIZE 2// 1st byte - Battery level length and type// 2nd~4th bytes - Battery values#define BAT_LEVEL_SIZE 3uint8_tV[FASTPAIR_ACCOUNT_KEY_SIZE+SALT_SIZE+BAT_LEVEL_SIZE+1]={0};intv_index=0;// The first 16 bytes are K.uint8_tK[FASTPAIR_ACCOUNT_KEY_SIZE]={0};fastpair_get_account_key_by_index(keyIndex,K);memcpy(V,K,FASTPAIR_ACCOUNT_KEY_SIZE);v_index=v_index+FASTPAIR_ACCOUNT_KEY_SIZE;// The next byte is the Salt.uint8_trandomSalt=(uint8_t)rand();V[v_index]=randomSalt;v_index=v_index+SALT_SIZE;// The remaining bytes are the battery information (from s + 1 to s + 4 including the length and type bytes).uint8_tbattery_level_len=0;uint8_tbattery_level[BAT_LEVEL_SIZE]={0};fastpair_get_bat_level(&battery_level_len,battery_level);// type = 0b0011 (show UI indication) or 0b0100 (hide UI indication)V[v_index]=(battery_level_len << 4|(is_show_ui?0x3:0x4));v_index=v_index+1;for(intidx=0;idx < battery_level_len;idx++){V[v_index++]=battery_level[idx];}
추적을 방지하기 위해 제공자는 원시 배터리 데이터를
늘어난다는 사실을 기억하세요. 대신에 연결되었을 때 RFCOMM을 통해 전송될 수 있습니다.
메시지 스트림: 기기 정보를 참조하세요.
[null,null,["최종 업데이트: 2025-08-13(UTC)"],[[["\u003cp\u003eProviders can include battery information for multiple components (e.g., earbuds and case) in the advertisement data using a specific format.\u003c/p\u003e\n"],["\u003cp\u003eThe advertisement data includes battery levels for each component and flags to control UI indication on the Seeker device.\u003c/p\u003e\n"],["\u003cp\u003eTo prevent tampering, the Account Key Data is modified to include battery information, requiring a specific construction process.\u003c/p\u003e\n"],["\u003cp\u003eProviders can choose to show or hide battery information in the Seeker's UI based on user interaction (e.g., case opening/closing).\u003c/p\u003e\n"],["\u003cp\u003eTo prevent tracking, raw battery data should not be constantly advertised but can be sent securely via RFCOMM after connection.\u003c/p\u003e\n"]]],[],null,["### Battery Notification\n\n| **Note:** Google recommends implementing the [Cryptographic Test Cases](/nearby/fast-pair/specifications/appendix/cryptotestcases \"Link to the Cryptographic Test Cases.\") to ease verification of these requirements.\n\nWhen a Provider includes multiple components, it can be useful to notify the\nSeeker of the battery level for each component. One example of this would be\nwhen a earbuds case is opened and the Seeker needs to know the battery for\neach individual bud and the case itself.\n\nTo accomplish this, a Provider can include additional information in the\nadvertisement, built on top of the Fast Pair Account Data described in\n[Advertising: When not discoverable](/nearby/fast-pair/specifications/service/provider#AdvertisingWhenNotDiscoverable \"Advertizing when not Discoverable\").\n\nIn addition to the Account Data, the Provider should include an additional field\nspecifying the battery values. The packet shall contain the following:\n\n| Octet | Data type | Description | Value | Mandatory? |\n|-----------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|------------|\n| 0 | `uint8` | Flags | 0x00 (all bits reserved for future use) | Mandatory |\n| 1 - *s* | | Account Key Data | Mandatory | |\n| *s + 1* | `uint8` | Battery level length and type 0bLLLLTTTT - L = Number of battery values - T = type | 0bLLLLTTTT - length = 0b0011 = 3 battery values - type = 0b0011 (show UI indication) or 0b0100 (hide UI indication) | Optional |\n| *s + 2* , *s + 3* , *s + 4* | `uint8` | Battery values 0bSVVVVVVV - S = status (charging or not charging) - V = value - The battery values should be ordered as left bud (*s + 2* ), right bud (*s + 3* ) and case (*s + 4*). | 0bSVVVVVVV - status = 0b1 (charging) or 0b0 (not charging) - value = battery level ranging from 0 to 100 percent, 0bS1111111 for unknown. | Optional |\n\nTo prevent tampering, the Account Key Data above shall be slightly\nmodified to include battery information when the battery values are included\nin the advertisement. Normally, when building the [account key\nfilter](/nearby/fast-pair/specifications/service/provider#AccountKeyFilter \"Account Key Filter\"), a value *V* is produced by combining the account\nkey with a salt. Instead, when battery information is also being advertised, the\nvalue *V* should be constructed as follows:\n\n1. Produce a value *V* , where:\n 1. The first 16 bytes are *K*.\n 2. The next bytes are the [Salt](/nearby/fast-pair/specifications/service/provider#SaltField \"Salt Field\").\n 3. The remaining bytes are the battery information (from *s + 1* to *s + 4* including the length and type byte from the table above).\n\nAs noted in the battery length and type field above, the type can be either\n`0b0011` or `0b0100`.\n\n- 0b0011 - Use when the Provider wants the Seeker to show an indication in the UI of the battery values;\n- 0b0100 - Use when the Provider wants the Seeker to hide the indication if it is already showing.\n\nOne common use case for this is to use `0b0011` when the case has opened and\n`0b0100` when buds have been removed from the case or it has been closed again. \n\n //The sample code demonstrates that the headset only reports the battery level.\n\n #define FASTPAIR_ACCOUNT_KEY_SIZE 16\n\n // In the sample code, the size of salt is 2 bytes.\n #define SALT_SIZE 2\n\n // 1st byte - Battery level length and type\n // 2nd~4th bytes - Battery values\n #define BAT_LEVEL_SIZE 3\n\n uint8_t V[FASTPAIR_ACCOUNT_KEY_SIZE + SALT_SIZE + BAT_LEVEL_SIZE + 1] = {0};\n int v_index = 0;\n\n // The first 16 bytes are K.\n uint8_t K[FASTPAIR_ACCOUNT_KEY_SIZE] = {0};\n fastpair_get_account_key_by_index(keyIndex, K);\n memcpy(V, K, FASTPAIR_ACCOUNT_KEY_SIZE);\n v_index = v_index + FASTPAIR_ACCOUNT_KEY_SIZE;\n\n // The next byte is the Salt.\n uint8_t randomSalt = (uint8_t)rand();\n V[v_index] = randomSalt;\n v_index = v_index + SALT_SIZE;\n\n // The remaining bytes are the battery information (from s + 1 to s + 4 including the length and type bytes).\n\n uint8_t battery_level_len = 0;\n uint8_t battery_level[BAT_LEVEL_SIZE] = {0};\n\n fastpair_get_bat_level(&battery_level_len, battery_level);\n\n // type = 0b0011 (show UI indication) or 0b0100 (hide UI indication)\n V[v_index] = (battery_level_len \u003c\u003c 4 | (is_show_ui ? 0x3 : 0x4));\n v_index = v_index + 1;\n\n for (int idx = 0; idx \u003c battery_level_len; idx++) {\n V[v_index++] = battery_level[idx];\n }\n\nTo prevent tracking, the Provider should not include raw battery data in the\nadvertisement all the time. It can instead be sent via RFCOMM when connected to\na Seeker, see [Message Stream: Device Information](/nearby/fast-pair/specifications/extensions/deviceinformation \"Message Stream: Device Information\")."]]