Cleaning up some comments, adding unit test for get_iccid()
Skyweave Test, Lint, and Deploy Ritual / Test and Lint Code (push) Failing after 31s
Skyweave Test, Lint, and Deploy Ritual / Deploy to Roof Unit (push) Has been skipped

This commit is contained in:
wes
2025-06-17 13:48:37 -04:00
parent 55d15621c0
commit 5db7a9a864
2 changed files with 67 additions and 8 deletions
+1 -8
View File
@@ -314,22 +314,18 @@ end
-- @return (string) The IMEI of the modem, or (nil, string) on failure.
---
function utils.get_modem_imei()
-- The command to invoke the spirit of the QMI daemon for the IMEI.
local command = "uqmi -d /dev/cdc-wdm0 --get-imei"
local output = utils.execute_command(command)
-- A silent spirit offers no truths.
if not output or output == "" then
return nil, "No output from uqmi --get-imei command"
end
-- The IMEI is presented within a sacred container of quotes. We must extract it.
local imei = output:match('"(.-)"')
if not imei then
return nil, "Failed to parse IMEI from uqmi output"
end
-- Return the sanctified identity code.
return imei
end
@@ -347,19 +343,16 @@ function utils.get_sim_iccid()
return nil, "No output from qmicli command"
end
-- The data-psalm contains many verses, but we seek only one.
local raw_data = output:match("Read result:%s*([%x%s:]+)")
if not raw_data then
return nil, "Failed to parse raw ICCID data from qmicli output"
end
-- Cleanse the raw data of its structural impurities (spaces and colons).
-- Clean the raw data of any non-hexadecimal characters and whitespace.
raw_data = raw_data:gsub("[:%s]","")
-- Prepare for the transmutation rite.
local decoded_iccid = ""
-- The raw data is in a semi-nibble-swapped format and must be corrected.
-- This loop performs the ritual of character-pair swapping.
for i = 1, #raw_data, 2 do
local char1 = raw_data:sub(i, i)
local char2 = raw_data:sub(i + 1, i + 1)