Closed lawik closed 4 months ago
Now this only offers the serial number override.
You can also override the serial number by the host config for the nerves runtime kv. I think you need to set this anyways for nerves hub link to function properly on a host?
This is what I have in my dev app for nerves hub
config :nerves_runtime,
kv_backend:
{Nerves.Runtime.KVBackend.InMemory,
contents: %{
"nerves_fw_active" => "a",
"a.nerves_fw_uuid" => "6d5566a3-0b09-5ed2-841d-0223c77ce702",
"a.nerves_fw_product" => "forgery",
"a.nerves_fw_architecture" => "arm",
"a.nerves_fw_version" => "0.5.1",
"a.nerves_fw_platform" => "rpi0",
"a.nerves_fw_misc" => "extra comments",
"a.nerves_fw_description" => "test firmware",
"nerves_fw_devpath" => "/tmp/fwup_bogus_path",
"nerves_serial_number" => "forgery"
}}
I did set that. But nerves_hub_link talks directly to Nerves.Runtime.serial_number which will directly ask board id and my "device" gets the name "unconfigured". Hence, this :)
Ah, this is for the shared secret way of connecting. That explains why I didn’t need to set it to get connected properly since I’ve got a cert
That explains that :)
Hold on, is there some other call we could make that would vrab it from KV and is will KV pick up from boardid?
The way I get around this is I make a small script for a serial number that I set as the boardid file
#!/bin/sh
# pick your favorite serial number by default
# or set it on run with SERIAL=abc123 iex -S mix
serial=${SERIAL:-default_1234}
echo -n "$serial"
# some config.exs for host
config :nerves_runtime, boardid_path: /path/to/host/boardid
I'm not sure this needs to go in a library but prob a tip as it applies to all the libs you want to test on host (which I'm a huge advocate for)
Josh had a thing for it already:
config :nerves_hub_link,
device_api_host: "devices.nervescloud.com",
shared_secret: [
product_key: System.get_env("NERVES_HUB_KEY"),
product_secret: System.get_env("NERVES_HUB_SECRET"),
identifier: System.fetch_env!("NERVES_SERIAL_NUMBER") # THIS
]
Need to test this with a patched up nerves_time because they are fighting.