- Fix leader election guard test for :undefined pid - Fix cpu_sup.util() pattern matching to handle numeric return - Fix encoding_utils to always return explicit nil when needed - Remove unused finite_float? function - Fix signal handler to match :ok return from :os.set_signal/2 - Remove redundant catch-all pattern in database metrics - Fix Gridsquare pattern matching in info_live template - Remove unnecessary nil check for calculate_course result - Fix get_packet_received_at to not check for nil (always returns DateTime) - Remove redundant catch-all pattern in weather format_weather_value - Fix query builder to use from(p in Packet) instead of bare Packet atom Reduced dialyzer errors from 49 to 6. Remaining warnings are mostly false positives from template compilation and overloaded function specs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
120 lines
4.5 KiB
Elixir
120 lines
4.5 KiB
Elixir
defmodule Aprsme.DeviceIdentificationTest do
|
|
use Aprsme.DataCase, async: true
|
|
|
|
alias Aprsme.DeviceIdentification
|
|
|
|
doctest DeviceIdentification
|
|
|
|
describe "identify_device/1" do
|
|
test "identifies Original MIC-E devices" do
|
|
assert DeviceIdentification.identify_device(" " <> <<0, 0>>) == "Original MIC-E"
|
|
end
|
|
|
|
test "identifies Kenwood devices" do
|
|
assert DeviceIdentification.identify_device(">" <> <<0>> <> "^") == "Kenwood TH-D74"
|
|
assert DeviceIdentification.identify_device(">" <> <<0, 0>>) == "Kenwood TH-D74A"
|
|
assert DeviceIdentification.identify_device("]" <> <<0>> <> "=") == "Kenwood DM-710"
|
|
assert DeviceIdentification.identify_device("]" <> <<0, 0>>) == "Kenwood DM-700"
|
|
end
|
|
|
|
test "identifies Yaesu devices" do
|
|
assert DeviceIdentification.identify_device("`_" <> " ") == "Yaesu VX-8"
|
|
assert DeviceIdentification.identify_device("`_" <> "\"") == "Yaesu FTM-350"
|
|
assert DeviceIdentification.identify_device("`_" <> "#") == "Yaesu VX-8G"
|
|
assert DeviceIdentification.identify_device("`_" <> "$") == "Yaesu FT1D"
|
|
assert DeviceIdentification.identify_device("`_" <> "%") == "Yaesu FTM-400DR"
|
|
assert DeviceIdentification.identify_device("`_" <> ")") == "Yaesu FTM-100D"
|
|
assert DeviceIdentification.identify_device("`_" <> "(") == "Yaesu FT2D"
|
|
end
|
|
|
|
test "identifies other devices" do
|
|
assert DeviceIdentification.identify_device("` X") == "AP510"
|
|
assert DeviceIdentification.identify_device("`" <> <<0, 0>>) == "Mic-Emsg"
|
|
assert DeviceIdentification.identify_device("'|3") == "Byonics TinyTrack3"
|
|
assert DeviceIdentification.identify_device("'|4") == "Byonics TinyTrack4"
|
|
|
|
assert DeviceIdentification.identify_device("':4") ==
|
|
"SCS GmbH & Co. P4dragon DR-7400 modems"
|
|
|
|
assert DeviceIdentification.identify_device("':8") ==
|
|
"SCS GmbH & Co. P4dragon DR-7800 modems"
|
|
|
|
assert DeviceIdentification.identify_device("'" <> <<0, 0>>) == "McTrackr"
|
|
assert DeviceIdentification.identify_device(<<0>> <> "\"" <> <<0>>) == "Hamhud"
|
|
assert DeviceIdentification.identify_device(<<0>> <> "/" <> <<0>>) == "Argent"
|
|
assert DeviceIdentification.identify_device(<<0>> <> "^" <> <<0>>) == "HinzTec anyfrog"
|
|
|
|
assert DeviceIdentification.identify_device(<<0>> <> "*" <> <<0>>) ==
|
|
"APOZxx www.KissOZ.dk Tracker. OZ1EKD and OZ7HVO"
|
|
|
|
assert DeviceIdentification.identify_device(<<0>> <> "~" <> <<0>>) == "Other"
|
|
end
|
|
|
|
test "returns Unknown for unidentified devices" do
|
|
assert DeviceIdentification.identify_device(<<0, 0, 0>>) == "Unknown"
|
|
end
|
|
end
|
|
|
|
describe "known_manufacturers/0" do
|
|
test "returns list of known manufacturers" do
|
|
manufacturers = DeviceIdentification.known_manufacturers()
|
|
assert is_list(manufacturers)
|
|
assert "Kenwood" in manufacturers
|
|
assert "Yaesu" in manufacturers
|
|
assert "Byonics" in manufacturers
|
|
end
|
|
end
|
|
|
|
describe "known_models/1" do
|
|
test "returns list of known models for Kenwood" do
|
|
models = DeviceIdentification.known_models("Kenwood")
|
|
assert is_list(models)
|
|
assert "TH-D74" in models
|
|
assert "TH-D74A" in models
|
|
assert "DM-710" in models
|
|
assert "DM-700" in models
|
|
end
|
|
|
|
test "returns list of known models for Yaesu" do
|
|
models = DeviceIdentification.known_models("Yaesu")
|
|
assert is_list(models)
|
|
assert "VX-8" in models
|
|
assert "FTM-350" in models
|
|
assert "VX-8G" in models
|
|
assert "FT1D" in models
|
|
assert "FTM-400DR" in models
|
|
assert "FTM-100D" in models
|
|
assert "FT2D" in models
|
|
end
|
|
|
|
test "returns empty list for unknown manufacturer" do
|
|
assert DeviceIdentification.known_models("Unknown") == []
|
|
end
|
|
end
|
|
|
|
describe "lookup_device_by_identifier/1" do
|
|
test "matches APSK21 to APS??? pattern" do
|
|
# Seed the devices table from the JSON
|
|
Aprsme.DevicesSeeder.seed_from_json()
|
|
|
|
# Should match
|
|
found = DeviceIdentification.lookup_device_by_identifier("APSK21")
|
|
assert found
|
|
assert found.identifier == "APS???"
|
|
assert found.model
|
|
assert found.vendor
|
|
end
|
|
|
|
test "matches Mic-E device identifier from raw packet" do
|
|
# Seed the devices table from the JSON
|
|
Aprsme.DevicesSeeder.seed_from_json()
|
|
|
|
# The device identifier extracted from the raw packet is "]="
|
|
found = DeviceIdentification.lookup_device_by_identifier("]=")
|
|
assert found
|
|
assert found.identifier == "]="
|
|
assert found.model
|
|
assert found.vendor
|
|
end
|
|
end
|
|
end
|