Codex reverse engineered my studio lights
I wanted my Amaran studio lights on the command line instead of in an iPad app. Codex spent about 26 hours in a goal loop cracking the Bluetooth commands, had me buy a Bluetooth sniffer board, and finally found the mesh network's app key in a SQLite database inside an iPad backup. Now one button on my Stream Deck turns every light on.
Everything I said
This is the Nordic nRF52840 DK. If you don't know what that is, I'd forgive you because I don't know what it is either. Codex told me to buy it because we have been trying to reverse engineer the Bluetooth mesh network for this. This is an Amaran light, and I have several of these here in the studio.
Okay? I've got one over here. This is my big light. This is my desk key. I've got three up behind me. I've got the kicker, and then I have two tube lights. Now, these are all very professional lights. They're great lights. I love them. They're all Amaran, uh, but they're controlled by this iPad app. They do have a desktop app. It sucks, but the iPad app is pretty good.
But as a developer, I want it on the command line. I wanna be able to wire it up to other scripts. I wanna push a button on my Stream Deck and just have all my lights come on. So Codex spent twenty-four hours and I spent maybe a hundred dollars on this board at Codex's direction and we now have the ability to press a button on my computer and have the lights turn on, or turn off, or turn on.
Or we have the ability to change the brightness. Did it work? I think it might have, so we can turn it back down. In fact, let's turn this one off. In fact, I can push a single button here and, boop, everything goes away. Hey, the lights turned off. Or push a single button and, boop, and we're ready to record.
Let's see how we did it. Before we get into the full backstory, here is my kind of control panel. This is a sort of graphic TUI, right? So I can use this to set the different scenes. Like I can turn all the lights off, or I can set it up for my R6, which is this main camera. This is really nice for tinkering with things and then saving the scene. But of course, I do have just a regular CLI.
So if I turn on the tall guy, which is this one, the tall guy turns on, and if I turn off the tall guy, it just turns back off. Now, I've wired that up to my Stream Deck so I can press a single button over here and all the lights go off and a single button over here and all the lights come back on. So how did we get there? Well, Codex, like I said, did most of the work.
I put it in a goal loop, and it spent about 26 hours just looping through trying different Bluetooth protocols, and it finally did crack it. This is how I started. This is the Amaran desktop application. And so I told Codex, "I need you to figure this desktop application out." So when you run a goal loop, basically you're telling Codex, "Keep going until you figure this goal out." And you always need some sort of thing that you're after and some sort of
way of verifying if you got there. And so for my goal loop, what I told it was, "Break into this desktop application for research purposes, and then try to send Bluetooth commands to this sentinel light right here. And then read back the status of the light from the desktop application." So now we have a, we have a successful verifiable loop.
It's gonna guess Bluetooth commands, and then it can read from the desktop application, did that command take? Did it actually work? So the desktop application served as our initial source of truth verifier while it was trying to decode and discover the Bluetooth commands. And it worked. After about 26 hours, that's how we ended up here, where I have this little CLI tool where I can turn a node on or off as long as it's paired to my computer, which is the next problem.
All of these lights in here, they all live inside of their own little mesh network. And to have my sentinel light join that mesh network, I needed a net key, an app key, a device key, an IV index, a sequence number. I needed, uh, a lot of stuff that I didn't actually have, which leads us to this guy, the Nordic nRF52840-DK eval board.
I'm sure you're super familiar with it, but forgive me because I wasn't, and what I learned is that this is a Bluetooth traffic sniffer, amongst other protocols. But for us, it was sniffing Bluetooth packets. So I put it between my iPad and the lights up there, and then I started controlling the lights from my iPad, and this thing captured all the Bluetooth traffic.
That's how we learned how to control the intensity, and the color temperature, and the green magenta, so that I can change the color of these tube lights behind me. What we also learned is that if you put this guy in pairing mode, it advertises a certain signature. So we copied that signature and made this thing advertise that signature.
Now, the iPad app thinks that this is an Amaran light. So I paired it from my iPad to this board, hoping, hoping that we could catch the app key. I want this thing to capture that app key so that new lights can join the existing mesh network.
I could make my own mesh network, but then it wouldn't show up on my iPad. And having it on my iPad is still really useful when I'm trying to walk around and tune the lights exactly correct, but then I wanna sit down at my desk and control it from the CLI. So my thought was, if this is a light and it pairs, we can capture the app key. We couldn't. Unfortunately, it didn't work, so that led us to the next step.
The next step was let's go after the iPad. The iPad obviously contains those keys for this existing mesh network. So I created an encrypted backup, put it on my Mac, and told Codex, "Go figure it out." What it found inside of the Sidus Link app was a SQLite database that contained the app key, the exact thing that we were missing.
So now I can add a new light on my iPad. My lighting guy can come in and adjust everything with the interface that he's used to with the iPad. And then from my desktop, I can still control that even though it was paired on my iPad. If I wanted to get away from the iPad altogether, I could just pair it with my desktop. I don't need the board, I don't need the Amaran desktop app, I don't need the iPad.
I have full control over all of my lights from the CLI. So now we're here. I can run bin Amaran list, and these are all of my lights. I gave a few of them a nice name. I can run bin Amaran on, and we'll turn on the tall guy. That's this one over here. It has a tall soft box, so I call it tall guy.
That is incredibly bright. Let's turn off tall guy. Now we have the building blocks. We're in a good spot, right? Now we have the building blocks, and of course, now we gotta put the building blocks together. So we added scenes. So if we look at, um, this is my Stream Deck directory right here, Stream Deck, and then I have an Amaran R6. So if I look at this file, you'll see all I need to do is apply the main R6 scene.
Main R6, this is my R6 camera, and I can turn on this scene. Another scene is the all-off scene. That turns everything off, which I probably shouldn't do while recording, so I'm gonna turn everything back on by using that scene. Now, we could, uh, we could just futz around with the command line, right? So if you look at this, you'll see, holy moly, this is all available on GitHub for research purposes only.
This is all available on GitHub, so you can, uh, discover, you can identify which flashes the lights. I love a CLI, especially for chaining things together. That's how I have my Stream Deck set up. But yeah, you know what? Maybe, maybe I actually wanna see a little, blah, maybe I wanna see a little bit of a GUI.
So I can come over here, and if I do tall guy again and hit identify, it's going to flash, which is kinda, ugh, it's kinda cool. Um, boy, it's really bright. I need to turn that down, which I can do by just turning this down. And then, you know, we'll use the keyboard to turn it up a notch, and then I can turn it back on. There we go. That's a little better.
Hey, look at that. Now, you'll see I have these two lights here. These lights are in the other room. They're a part of a different mesh network, so I need to have these join. But now I can come in here, and let's click over here and say, "I wanna capture this one, this one, this one, and this one, and I want this one as well, and I wanna save that as a new scene." And so if I save that as a new scene, then that's available here in the TUI, of course, but it's available on the command line
as well. These tube lights behind me have green magenta, so I can change the color and not only the color temperature. So if I turn the brightness on this one all the way up, this one is over here. I'm gonna turn tube stage left off, and then I can change, we'll change the temperature and the green magenta, and you'll see that that color behind me starts to change.
So there's the magenta. I can turn this down, and it changes colors again. Oh, that's nice. But you know, we're recording a video. Let's turn on the main R6 scene again. Now, why do something like this? Why not just use the iPad app or the desktop app? Because I freaking wanted to. It's the golden age of tinkering.
Look, this is cool. I don't really still know how this works, but this is freaking awesome, and I'm glad that I have it now. You can build anything, and I think you should start by building things that make your life easier. Now I can push a button and everything works. Now I can tell my agent, "Hey, why don't we set up a new scene?
Turn this light down a little. Turn that light up a little. Make those lights a little more green or orange or whatever." It's so fun. So my encouragement to you is to go out and build something. Ask your agents, "How do we do this? I've got a couple ideas. What do you think? Let's work together." Just talk to the agent. I didn't use any special frameworks, any special tooling. I just talked to the agent.
So I'll put all this on GitHub. I hope you enjoy it. And until the next time, see ya.