koenvervloesem / openhaystack-zephyr

Zephyr-based OpenHaystack firmware to track your personal Bluetooth devices via Apple's Find My network
MIT License
49 stars 6 forks source link

Deploying firmware onto nRF52840 dongle #1

Closed craig-coburn closed 2 years ago

craig-coburn commented 2 years ago

Hey I really appreciate your work and it's working really well so far. I just have a brief question on deploying the device using OpenHaystack. I am using version 051 and have also tested on version 036 and I am unable to get the device to deploy on this software. In regards to hardcoding the base64 advertisement key, I have copied this directly from OpenHaystack and tried replacing the recommended line in the main.c file in the apps folder but this has not been effective at deploying the device. Could you please walk me through the process with more instruction on the other method to connect the base64 advertisement key from OpenHaystack and my device? Which .bin file is the openhaystack.sh file requesting as input to deploy the device? I have been able to successfully flash the firmware onto this nRF dongle with no issues whatsoever with your instruction.

Many thanks.

koenvervloesem commented 2 years ago

So one way is:

This only works with the raw string, not with the Base64 encoded key.

If you have the Base64 advertisement key, for instance from the OpenHaystack app, you should run the openhaypatch.sh script as follows, after building your code with west build:

./openhaypatch.sh build/zephyr/zephyr.bin <base64 key>

This patches the file in build/zephyr/zephyr.bin.

craig-coburn commented 2 years ago

Thank you for your reply. Could I also please ask how long after you initially flashed your nRF dongle you started seeing the location data on OpenHaystack and what version of OpenHaystack you were using?

koenvervloesem commented 2 years ago

Well, if you're lucky you should see your location in the OpenHaystack software on your Mac after a few minutes, but it can also easily take an hour or so, depending on the number of Apple devices in your neighborhood and when they relay the Find My data to Apple.

I don't remember the exact release I used last time I tried this firmware with OpenHaystack. This was in July 2021 :-)

craig-coburn commented 2 years ago

I am able to build and flash the firmware with no issues whatsoever and can find it on the airguard application but cannot get it to appear on OpenHaystack. Do you have any suggestions going forward? I am building and flashing the firmware on a Mac OS Big Sur operating system. To my understanding, the nRF SDK is not on MAC OS so I cannot load a soft device hex file onto the dongle. Did you need to upload a soft device to receive these advertisements on openhaystack or is there something else I can try? The picture shows the advertisements from an ESP32 (second FindMy device). using another repository and the dongle. Only the ESP shows on OpenHaystack

koenvervloesem commented 2 years ago

No I didn't need the SoftDevice BLE controller, as Zephyr has a complete BLE stack.

I'm puzzled that it doesn't work, as my code is doing the same as the OpenHaystack ESP32 code.

Maybe try to build the firmware with the USB UART overlay and look at the logs with screen?

craig-coburn commented 2 years ago

Apologies, I'm a bit unfamiliar with how I can view the UART logs - to update on progress, I have installed and built the firmware on Ubuntu 20.04 and this was much easier than using MacOS. However, still having the same issue. Another warning I am noticing is that the array of char for the public advertisement key may be too long. As input, I have tried the byte array and escaped string versions of the public key that are taken directly from the latest version of OpenHaystack, but I believe that I may have the incorrect format. I was uncertain whether patching the .bin file after running the make command updated the .hex file that was flashed onto the dongle so I have been updating the public key directly in the main.c file. Many thanks again. Screenshot from 2022-02-13 22-26-03 Here's another error I get when using the second build option: Screenshot from 2022-02-13 22-46-52

koenvervloesem commented 2 years ago

For the UART logs: run ls /dev/tty* (Linux) or ls /dev/cu.* (macOS) in a terminal window, connect your board and run the command again to check which port appears. On Linux, this will probably be /dev/ttyACM0. Then run screen /dev/ttyACM0 115200 to connect to port /dev/ttyACM0 with a speed of 115200 bits per second.

The warnings about the default values for the USB vendor and product ID are harmless, this doesn't affect the functionality.

The error about the char array is important, though. You have to initialize it like this:

static char public_key[28] = {0x61, 0xc4, 0xc2, 0x55, ...}

Just fill in all bytes of the key instead of the ellipsis. Note that it doesn't have double or single quotes in this case, as you're creating an array of bytes now, while the example key is created as a string for easier identification.

craig-coburn commented 2 years ago

Works perfectly. Thank you for your time and patience!

koenvervloesem commented 2 years ago

Thank you for your questions, they made me clarify some topics that weren't fleshed out enough in the README: https://github.com/koenvervloesem/openhaystack-zephyr/commit/857b2c52afb9457f4883834e9bd74fb77d2d2c14