From dad5f4fc11c3249d621c1038f053dd0d090f2597 Mon Sep 17 00:00:00 2001 From: DigiH Date: Fri, 22 Dec 2023 12:33:50 +0100 Subject: [PATCH] Apple Watch, iPhone and iPad adjustments (#476) (#477) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Changed state string property to boolean unlocked - for Apple Watch, iPhone and iPad • iPhone/iPad doc added --- docs/devices/AppleDevice.md | 17 +++++++++++++++++ docs/devices/AppleWatch.md | 6 +++--- src/devices/APPLEDEVICE_json.h | 18 +++++++++--------- src/devices/APPLEWATCH_json.h | 21 ++++++++++++--------- tests/BLE/test_ble.cpp | 16 ++++++++-------- 5 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 docs/devices/AppleDevice.md diff --git a/docs/devices/AppleDevice.md b/docs/devices/AppleDevice.md new file mode 100644 index 00000000..d8c2b2de --- /dev/null +++ b/docs/devices/AppleDevice.md @@ -0,0 +1,17 @@ +# Apple iPhone/iPad + +|Model Id|[APPLEDEVICE](https://github.com/theengs/decoder/blob/development/src/devices/APPLEDEVICE_json.h)| +|-|-| +|Brand|Apple| +|Model|Apple iPhone/iPad| +|Short Description|Various Apple iPhone/iPad models| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power Source|Rechargeable battery| +|Exchanged Data|unlocked| +|Encrypted|No| +|Presence Tracker|✅| + +Currently only usefully working with the [Theengs Gateway](https://gateway.theengs.io/use/use.html#details-options) **Identity Address** and **IRK** functionality, to be able to decrypt the randomly changing Bluetooth MAC address to the static identity MAC address. + +Instructions on how to get the [Identity Address and IRK for an Apple Watch, iPhone or iPad](https://gateway.theengs.io/use/use.html#getting-identity-resolving-key-irk-for-apple-watch-iphone-and-ipad) diff --git a/docs/devices/AppleWatch.md b/docs/devices/AppleWatch.md index d1f8490c..a6509ad1 100644 --- a/docs/devices/AppleWatch.md +++ b/docs/devices/AppleWatch.md @@ -2,13 +2,13 @@ |Model Id|[APPLEWATCH](https://github.com/theengs/decoder/blob/development/src/devices/APPLEWATCH_json.h)| |-|-| -|Brand|Apple Watch| -|Model|Smart watch| +|Brand|Apple| +|Model|Apple Watch| |Short Description|Various Apple Watch models| |Communication|BLE broadcast| |Frequency|2.4Ghz| |Power Source|Rechargeable battery| -|Exchanged Data|locked/unlocked state| +|Exchanged Data|unlocked| |Encrypted|No| |Presence Tracker|✅| diff --git a/src/devices/APPLEDEVICE_json.h b/src/devices/APPLEDEVICE_json.h index c0f6d0f1..d948ca98 100644 --- a/src/devices/APPLEDEVICE_json.h +++ b/src/devices/APPLEDEVICE_json.h @@ -1,4 +1,4 @@ -const char* _APPLEDEVICE_json = "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"tag\":\"1018\",\"condition\":[\"manufacturerdata\",\">=\",8,\"index\",0,\"4c0010\"],\"properties\":{\"state\":{\"condition\":[\"manufacturerdata\",9,\"b\"],\"decoder\":[\"static_value\",\"unlocked recent authenticated interaction\"]},\"_state\":{\"condition\":[\"manufacturerdata\",9,\"!\",\"b\"],\"decoder\":[\"static_value\",\"locked\"]}}}"; +const char* _APPLEDEVICE_json = "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"tag\":\"1018\",\"condition\":[\"manufacturerdata\",\">=\",8,\"index\",0,\"4c0010\"],\"properties\":{\"unlocked\":{\"condition\":[\"manufacturerdata\",9,\"b\"],\"decoder\":[\"static_value\",true]},\"_unlocked\":{\"condition\":[\"manufacturerdata\",9,\"!\",\"b\"],\"decoder\":[\"static_value\",false]}}}"; /*R""""( { "brand":"Apple", @@ -7,24 +7,24 @@ const char* _APPLEDEVICE_json = "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/i "tag":"1018", "condition":["manufacturerdata", ">=", 8, "index", 0, "4c0010"], "properties":{ - "state":{ + "unlocked":{ "condition":["manufacturerdata", 9, "b"], - "decoder":["static_value", "unlocked recent authenticated interaction"] + "decoder":["static_value", true] }, - "_state":{ + "_unlocked":{ "condition":["manufacturerdata", 9, "!", "b"], - "decoder":["static_value", "locked"] + "decoder":["static_value", false] } } })"""";*/ -const char* _APPLEDEVICE_json_props = "{\"properties\":{\"state\":{\"unit\":\"string\",\"name\":\"state\"}}}"; +const char* _APPLEDEVICE_json_props = "{\"properties\":{\"unlocked\":{\"unit\":\"status\",\"name\":\"lock\"}}}"; /*R""""( { "properties":{ - "state":{ - "unit":"string", - "name":"state" + "unlocked":{ + "unit":"status", + "name":"lock" } } })"""";*/ diff --git a/src/devices/APPLEWATCH_json.h b/src/devices/APPLEWATCH_json.h index bf78fec2..f1ab7960 100644 --- a/src/devices/APPLEWATCH_json.h +++ b/src/devices/APPLEWATCH_json.h @@ -1,4 +1,4 @@ -const char* _APPLEWATCH_json = "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"tag\":\"0b18\",\"condition\":[\"manufacturerdata\",\"index\",10,\"98\",\"|\",\"manufacturerdata\",\"index\",10,\"18\",\"&\",\"manufacturerdata\",\"=\",18,\"index\",0,\"4c001005\"],\"properties\":{\"state\":{\"decoder\":[\"string_from_hex_data\",\"manufacturerdata\",10,2],\"lookup\":[\"98\",\"unlocked\",\"18\",\"locked\"]}}}"; +const char* _APPLEWATCH_json = "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"tag\":\"0b18\",\"condition\":[\"manufacturerdata\",\"index\",10,\"98\",\"|\",\"manufacturerdata\",\"index\",10,\"18\",\"&\",\"manufacturerdata\",\"=\",18,\"index\",0,\"4c001005\"],\"properties\":{\"unlocked\":{\"condition\":[\"manufacturerdata\",10,\"98\"],\"decoder\":[\"static_value\",true]},\"_unlocked\":{\"condition\":[\"manufacturerdata\",10,\"18\"],\"decoder\":[\"static_value\",false]}}}"; /*R""""( { "brand":"Apple", @@ -7,21 +7,24 @@ const char* _APPLEWATCH_json = "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\ "tag":"0b18", "condition":["manufacturerdata", "index", 10, "98", "|", "manufacturerdata", "index", 10, "18", "&", "manufacturerdata", "=", 18, "index", 0, "4c001005"], "properties":{ - "state":{ - "decoder":["string_from_hex_data", "manufacturerdata", 10, 2], - "lookup":["98", "unlocked", - "18", "locked"] + "unlocked":{ + "condition":["manufacturerdata", 10, "98"], + "decoder":["static_value", true] + }, + "_unlocked":{ + "condition":["manufacturerdata", 10, "18"], + "decoder":["static_value", false] } } })"""";*/ -const char* _APPLEWATCH_json_props = "{\"properties\":{\"state\":{\"unit\":\"string\",\"name\":\"state\"}}}"; +const char* _APPLEWATCH_json_props = "{\"properties\":{\"unlocked\":{\"unit\":\"status\",\"name\":\"lock\"}}}"; /*R""""( { "properties":{ - "state":{ - "unit":"string", - "name":"state" + "unlocked":{ + "unit":"status", + "name":"lock" } } })"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 7ff2ddb7..8525d936 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -133,16 +133,16 @@ const char* expected_mfg[] = { "{\"brand\":\"Oral-B\",\"model\":\"BT Toothbrush\",\"model_id\":\"ORALB_BT\",\"type\":\"BODY\",\"state\":\"sleeping\",\"mode\":\"turbo\",\"sector\":\"sector 8\",\"pressure\":32,\"duration\":135}", "{\"brand\":\"GENERIC\",\"model\":\"BM6 Battery Monitor\",\"model_id\":\"BM6\",\"type\":\"BATT\",\"track\":true,\"batt\":77,\"device\":\"BM6 Tracker\"}", "{\"brand\":\"GENERIC\",\"model\":\"BM6 Battery Monitor\",\"model_id\":\"BM6\",\"type\":\"BATT\",\"track\":true,\"batt\":78,\"device\":\"BM6 Tracker\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"prmac\":true,\"state\":\"locked\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"prmac\":true,\"state\":\"unlocked\"}", + "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"prmac\":true,\"unlocked\":false}", + "{\"brand\":\"Apple\",\"model\":\"Apple Watch\",\"model_id\":\"APPLEWATCH\",\"type\":\"BODY\",\"track\":true,\"prmac\":true,\"unlocked\":true}", "{\"brand\":\"Aranet\",\"model\":\"Aranet4 CO₂ Monitor\",\"model_id\":\"ARANET4\",\"type\":\"AIR\",\"tempc\":26,\"tempf\":78.8,\"hum\":19,\"pres\":804,\"co2\":879,\"batt\":98}", "{\"brand\":\"Aranet\",\"model\":\"Aranet4 CO₂ Monitor\",\"model_id\":\"ARANET4\",\"type\":\"AIR\",\"tempc\":26.3,\"tempf\":79.34,\"hum\":17,\"pres\":803.2,\"co2\":844,\"batt\":98}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"locked\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"locked\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"unlocked recent authenticated interaction\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"locked\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"locked\"}", - "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"state\":\"unlocked recent authenticated interaction\"}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":true}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}", + "{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":true}", }; const char* expected_name_uuid_mfgsvcdata[] = {