Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An example scanner to collect Manufacturer Specific Data. #71

Merged
merged 4 commits into from
Dec 9, 2021

Conversation

angrycandy
Copy link
Contributor

@angrycandy angrycandy commented Sep 20, 2021

Raspberry Pi Zero W results:

iex(1)> {:ok, pid} = BlueHeronScan.start_link(:uart, %{device: "ttyS0"})
{:ok, #PID<0.10860.0>}
iex(2)> state = :sys.get_state(pid)
%{
  ctx: #BlueHeron.Context<0.10861.0>,
  devices: %{
    4753574963174 => %{
      272 => <<64, 10, 1, 0>>,
      :name => "Bose AE2 SoundLink",
      :time => ~U[2021-09-27 14:48:25.778174Z]
    },
    48660401950223 => %{
      784 => <<64, 16, 2, 48>>,
      :name => "LE-Bose Revolve SoundLink",
      :time => ~U[2021-09-27 14:48:25.658670Z]
    },
    110946934216995 => %{
      117 => <<66, 4, 1, 128, 102, 100, 231, 216, 154, 89, 35, 102, 231, 216,
        154, 89, 34, 1, 62, 0, 0, 0, 0, 0>>,
      :time => ~U[2021-09-27 14:48:25.873323Z]
    },
    181149778439893 => %{
      1 => <<1, 1, 4, 28, 196, 90>>,
      :name => "GVH5102_EED5",
      :time => ~U[2021-09-27 14:48:26.032518Z]
    },
    181149781445015 => %{
      name: "ihoment_H6182_C997",
      time: ~U[2021-09-27 14:48:26.059225Z]
    },
    246390811914386 => %{
      60552 => <<0, 97, 10, 12, 22, 100, 2>>,
      :name => "Govee_H5074_F092",
      :time => ~U[2021-09-27 14:48:24.429195Z]
    }
  },
  ignore_cids: [6, 76],
  working: true
}
iex(3)> BlueHeronScan.ignore_cids(pid, MapSet.new([6, 76, 117, 784]))
{:ok, #MapSet<[6, 76, 117, 784]>}
iex(4)> BlueHeronScan.clear_devices(pid)
:ok
iex(5)> state = :sys.get_state(pid)
%{
  ctx: #BlueHeron.Context<0.10861.0>,
  devices: %{
    4753574963174 => %{
      272 => <<64, 10, 1, 0>>,
      :name => "Bose AE2 SoundLink",
      :time => ~U[2021-09-27 14:48:46.192324Z]
    },
    181149778439893 => %{
      1 => <<1, 1, 4, 28, 196, 90>>,
      :name => "GVH5102_EED5",
      :time => ~U[2021-09-27 14:48:46.287562Z]
    },
    181149781445015 => %{
      name: "ihoment_H6182_C997",
      time: ~U[2021-09-27 14:48:47.139443Z]
    },
    246390811914386 => %{
      60552 => <<0, 94, 10, 11, 22, 100, 2>>,
      :name => "Govee_H5074_F092",
      :time => ~U[2021-09-27 14:48:45.477457Z]
    }
  },
  ignore_cids: #MapSet<[6, 76, 117, 784]>,
  working: true
}
iex(6)> BleAdMfgData.print(state.devices)
[
  ["26.5˚C 56.4% RH 100%🔋", "Govee_H5074_F092"],
  ["27.0˚C 50.8% RH 90%🔋", "GVH5102_EED5"]
]
iex(7)> BlueHeronScan.disable(pid)
:ok
iex(8)> BlueHeronScan.clear_devices(pid)
:ok
iex(9)> state = :sys.get_state(pid)
%{
  ctx: #BlueHeron.Context<0.10861.0>,
  devices: %{},
  ignore_cids: #MapSet<[6, 76, 117, 784]>,
  working: true
}
iex(10)> BlueHeronScan.enable(pid)
:ok
iex(11)> 

@ConnorRigby
Copy link
Collaborator

Sorry for the long wait on reviewing this. It looks good to me and i'd love to merge it! Could you make API functions for the server instead of using :sys.get_state/1? after that, i'll merge!

@angrycandy
Copy link
Contributor Author

Sorry for the long wait on reviewing this. It looks good to me and i'd love to merge it! Could you make API functions for the server instead of using :sys.get_state/1? after that, i'll merge!

Done!

@ConnorRigby ConnorRigby merged commit 7b903b7 into blue-heron:main Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants