Skip to content

Commit

Permalink
Lid open counter
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Oct 31, 2024
1 parent 31fa288 commit 10a8b9f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
16 changes: 10 additions & 6 deletions src/devices/APPLEAIRPODS_json.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const char* _APPLEAIRPODS_json = "{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"tag\":\"1208\",\"condition\":[\"manufacturerdata\",\"index\",8,\"01\",\"&\",\"manufacturerdata\",\"=\",58,\"index\",0,\"4c0007\"],\"properties\":{\"version\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your model version\"]},\"_version\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,4],\"lookup\":[\"0220\",\"AirPods\",\"0e20\",\"AirPods Pro\",\"0620\",\"AirPods Pro 1st gen.\",\"1420\",\"AirPods Pro 2nd gen.\",\"0320\",\"Powerbeats3\",\"0520\",\"BeatsX\",\"0620\",\"Beats Solo3\"]},\"color\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your color\"]},\"_color\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",21,2],\"lookup\":[\"00\",\"white\",\"10\",\"white\",\"20\",\"white\",\"15\",\"white\",\"01\",\"black\",\"02\",\"red\",\"03\",\"blue\",\"04\",\"pink\",\"05\",\"gray\",\"06\",\"silver\",\"07\",\"gold\",\"08\",\"rose gold\",\"09\",\"space gray\",\"0a\",\"dark blue\",\"0b\",\"light blue\",\"0c\",\"yellow\"]},\"status\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your status\"]},\"_status\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",14,2],\"lookup\":[\"55\",\"Both AirPods in case\",\"75\",\"Both AirPods in case\",\"22\",\"Both AirPods not in case ??\"]},\"batt_r\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",16,1],\"post_proc\":[\"*\",10,\"max\",100]},\"batt_l\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",17,1],\"post_proc\":[\"*\",10,\"max\",100]},\"batt_case\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",19,1],\"post_proc\":[\"*\",10,\"max\",100]},\"charging_r\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,1,false,true]},\"charging_l\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,0,false,true]},\"charging_case\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,2,false,true]}}}";
const char* _APPLEAIRPODS_json = "{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"tag\":\"1208\",\"condition\":[\"manufacturerdata\",\"index\",8,\"01\",\"&\",\"manufacturerdata\",\"=\",58,\"index\",0,\"4c0007\"],\"properties\":{\"version\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your model version\"]},\"_version\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,4],\"lookup\":[\"0220\",\"AirPods\",\"0e20\",\"AirPods Pro\",\"0620\",\"AirPods Pro 1st gen.\",\"1420\",\"AirPods Pro 2nd gen.\",\"0320\",\"Powerbeats3\",\"0520\",\"BeatsX\",\"0620\",\"Beats Solo3\"]},\"color\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your color\"]},\"_color\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",22,2],\"lookup\":[\"00\",\"white\",\"01\",\"black\",\"02\",\"red\",\"03\",\"blue\",\"04\",\"pink\",\"05\",\"gray\",\"06\",\"silver\",\"07\",\"gold\",\"08\",\"rose gold\",\"09\",\"space gray\",\"0a\",\"dark blue\",\"0b\",\"light blue\",\"0c\",\"yellow\"]},\"status\":{\"decoder\":[\"static_value\",\"thus far unknown - please report your status\"]},\"_status\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",14,2],\"lookup\":[\"55\",\"Both AirPods in case\",\"75\",\"Both AirPods in case\",\"22\",\"Both AirPods not in case ??\"]},\"batt_r\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",16,1],\"post_proc\":[\"*\",10,\"max\",100]},\"batt_l\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",17,1],\"post_proc\":[\"*\",10,\"max\",100]},\"batt_case\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",19,1],\"post_proc\":[\"*\",10,\"max\",100]},\"lid_open\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,2]},\"charging_r\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,1,false,true]},\"charging_l\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,0,false,true]},\"charging_case\":{\"decoder\":[\"bit_static_value\",\"manufacturerdata\",18,2,false,true]}}}";
/*R""""(
{
"brand":"Apple/Beats",
Expand All @@ -24,11 +24,8 @@ const char* _APPLEAIRPODS_json = "{\"brand\":\"Apple/Beats\",\"model\":\"AirPods
"decoder":["static_value", "thus far unknown - please report your color"]
},
"_color":{
"decoder":["string_from_hex_data", "manufacturerdata", 21, 2],
"decoder":["string_from_hex_data", "manufacturerdata", 22, 2],
"lookup":["00", "white",
"10", "white",
"20", "white",
"15", "white",
"01", "black",
"02", "red",
"03", "blue",
Expand Down Expand Up @@ -63,6 +60,9 @@ const char* _APPLEAIRPODS_json = "{\"brand\":\"Apple/Beats\",\"model\":\"AirPods
"decoder":["value_from_hex_data", "manufacturerdata", 19, 1],
"post_proc":["*", 10, "max", 100]
},
"lid_open":{
"decoder":["value_from_hex_data", "manufacturerdata", 20, 2]
},
"charging_r":{
"decoder":["bit_static_value", "manufacturerdata", 18, 1, false, true]
},
Expand All @@ -75,7 +75,7 @@ const char* _APPLEAIRPODS_json = "{\"brand\":\"Apple/Beats\",\"model\":\"AirPods
}
})"""";*/

const char* _APPLEAIRPODS_json_props = "{\"properties\":{\"version\":{\"unit\":\"string\",\"name\":\"model version\"},\"color\":{\"unit\":\"string\",\"name\":\"color\"},\"status\":{\"unit\":\"string\",\"name\":\"status\"},\"batt_r\":{\"unit\":\"%\",\"name\":\"batt\"},\"batt_l\":{\"unit\":\"%\",\"name\":\"batt\"},\"batt_case\":{\"unit\":\"%\",\"name\":\"batt\"},\"charging_r\":{\"unit\":\"status\",\"name\":\"battery_charging\"},\"charging_l\":{\"unit\":\"status\",\"name\":\"battery_charging\"},\"charging_case\":{\"unit\":\"status\",\"name\":\"battery_charging\"}}}";
const char* _APPLEAIRPODS_json_props = "{\"properties\":{\"version\":{\"unit\":\"string\",\"name\":\"model version\"},\"color\":{\"unit\":\"string\",\"name\":\"color\"},\"status\":{\"unit\":\"string\",\"name\":\"status\"},\"batt_r\":{\"unit\":\"%\",\"name\":\"batt\"},\"batt_l\":{\"unit\":\"%\",\"name\":\"batt\"},\"batt_case\":{\"unit\":\"%\",\"name\":\"batt\"},\"lid_open\":{\"unit\":\"int\",\"name\":\"lid open counter\"},\"charging_r\":{\"unit\":\"status\",\"name\":\"battery_charging\"},\"charging_l\":{\"unit\":\"status\",\"name\":\"battery_charging\"},\"charging_case\":{\"unit\":\"status\",\"name\":\"battery_charging\"}}}";
/*R""""(
{
"properties":{
Expand Down Expand Up @@ -103,6 +103,10 @@ const char* _APPLEAIRPODS_json_props = "{\"properties\":{\"version\":{\"unit\":\
"unit":"%",
"name":"batt"
},
"lid_open":{
"unit":"int",
"name":"lid open counter"
},
"charging_r":{
"unit":"status",
"name":"battery_charging"
Expand Down
21 changes: 9 additions & 12 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,15 @@ const char* expected_mfg[] = {
"{\"brand\":\"Onset\",\"model\":\"Hobo Water Level Sensor\",\"model_id\":\"HOBOMX2001\",\"type\":\"UNIQ\",\"lvl_cm\":8.46760273,\"lvl_in\":3.333701862}",
"{\"brand\":\"Onset\",\"model\":\"Hobo Water Level Sensor\",\"model_id\":\"HOBOMX2001\",\"type\":\"UNIQ\",\"lvl_cm\":9.514185786,\"lvl_in\":3.745742436}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"tempc\":25.5,\"tempf\":77.9,\"hum\":50,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro\",\"color\":\"white\",\"status\":\"Both AirPods not in case ??\",\"batt_r\":100,\"batt_l\":50,\"batt_case\":100,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 1st gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":50,\"batt_case\":100,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":100,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"Both AirPods in case\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"charging_r\":true,\"charging_l\":true,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":100,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":90,\"batt_l\":90,\"batt_case\":70,\"charging_r\":false,\"charging_l\":true,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":70,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"Both AirPods in case\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":70,\"charging_r\":true,\"charging_l\":true,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro\",\"color\":\"white\",\"status\":\"Both AirPods not in case ??\",\"batt_r\":100,\"batt_l\":50,\"batt_case\":100,\"lid_open\":0,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":100,\"lid_open\":0,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"lid_open\":17,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"Both AirPods in case\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"lid_open\":50,\"charging_r\":true,\"charging_l\":true,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":30,\"lid_open\":18,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":100,\"batt_case\":100,\"lid_open\":18,\"charging_r\":false,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":90,\"batt_l\":90,\"batt_case\":70,\"lid_open\":50,\"charging_r\":false,\"charging_l\":true,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"thus far unknown - please report your status\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":70,\"lid_open\":17,\"charging_r\":true,\"charging_l\":false,\"charging_case\":false}",
"{\"brand\":\"Apple/Beats\",\"model\":\"AirPods (Pro)/Solo|Studio Buds\",\"model_id\":\"APPLEAIRPODS\",\"type\":\"AUDIO\",\"track\":true,\"version\":\"AirPods Pro 2nd gen.\",\"color\":\"white\",\"status\":\"Both AirPods in case\",\"batt_r\":100,\"batt_l\":90,\"batt_case\":70,\"lid_open\":50,\"charging_r\":true,\"charging_l\":true,\"charging_case\":false}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -675,7 +674,6 @@ const char* test_mfgdata[][3] = {
{"Hobo Water Level", "", "c500073fd54f010624000000080092a901a0bcd9c23d"},
{"SwitchBot Outdoor Meter Manufacturerdata", "WoIOSensorTH", "6909aabbccddeeff8b0305993200"},
{"Apple", "AirPods", "4c000719010e2022f58f00000a7d9fff27234873d4305e0fed1b39e2b8"},
{"Apple", "AirPods", "4c00071901062000f58f015c007d7863dd4c2026d1cfb8fe1a344f24cf"},
{"Apple?", "AirPods", "4c000719010e2002f98f0000058de7929a3aa09ed6fbb010db935b056c"},
{"Apple?", "AirPods", "4c00071901142011aaa3110004254f0c5375c903064e61be2590411d53"},
{"Apple?", "AirPods", "4c00071901142075aab3320004336834816d0f667558352a4e211589aa"},
Expand Down Expand Up @@ -843,7 +841,6 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::APPLEAIRPODS,
TheengsDecoder::BLE_ID_NUM::APPLEAIRPODS,
TheengsDecoder::BLE_ID_NUM::APPLEAIRPODS,
TheengsDecoder::BLE_ID_NUM::APPLEAIRPODS,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down

0 comments on commit 10a8b9f

Please sign in to comment.