Skip to content

Commit

Permalink
Add case for bad service data
Browse files Browse the repository at this point in the history
  • Loading branch information
danielspofford committed May 19, 2019
1 parent 6d3206b commit 304b377
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/harald/hci/event/le_meta/advertising_report/device.ex
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,24 @@ defmodule Harald.HCI.Event.LEMeta.AdvertisingReport.Device do
end
end

def deserialize_ads(<<GenericAccessProfile.id("Service Data - 32-bit UUID"), bin::binary>>) do
<<
uuid::little-size(32),
data::binary
>> = bin
def deserialize_ads(
<<GenericAccessProfile.id("Service Data - 32-bit UUID"), tail::binary>> = bin
) do
case tail do
<<
uuid::little-size(32),
data::binary
>> ->
service_data_32 = %{
uuid: uuid,
data: data
}

service_data_32 = %{
uuid: uuid,
data: data
}
{:ok, {"Service Data - 32-bit UUID", service_data_32}}

{:ok, {"Service Data - 32-bit UUID", service_data_32}}
_ ->
{:error, bin}
end
end

def deserialize_ads(<<type, bin::bits>>) when type in GenericAccessProfile.ids() do
Expand Down

0 comments on commit 304b377

Please sign in to comment.