Reverse Engineering A Hydra 26 Hd
Well I haven't updated in a while...so here's a quick one. Skip to below the photo's, for the main reason for this thread.
I've added two clowns, who proceeded to decimate my pod population and seem to be pretty happy now. I've also added a few turbos and a peppermint shrimp (we've two more to pick up tomorrow). I've also added a Tunze Nanonstream 6040, for some extra flow. Now for the obligatory photo's
As you can see I ended up buying a Hydra 26 HD...it's not off center any more.
The clownbabies (Madam Mim & Merlin....I blame my girlfriend for those names)
Slightly blurry but here is that fungia, that was in the middle of my live rock. I've extracted him
Now, onto the main event. As you can see, I caved...I was finding it hard to build out what I wanted on a small scale, for lighting...if I was building a bigger rig, I could make it work but for this it ended up working better for me, to buy off the shelf....but that won't stop me trying to tinker around with it :)
WARNING: Now, before we got any further....there be dragons...anything I'm messing with below, is for my own entertainment. You may be violating the warranty, by messing with these APIs below.
My Problem:
I've grabbed some aip files, with some sample programs, for the lights but they don't quite match what I want...I could write a script to change them to timeshift them to run earlier in the day and reduce the intensity (they're too strong from my tank, sometimes) but the problem is that there's a checksum in the file, which fails if I edit the file before uploading it.
My Goals:
Let's see if we can figure out how the checksum is being calculated.
The Analysis:
I did a bit of digging through the code, for the web ui, for my Hydra 26 HD and it lead me to notice a check for a cookie called "web_goblins" if it was true then it would add new elements to the page...turns out there's an API that I can query. A quick change in Chrome developers tools...
View attachment ai.imgur.com_43Ah2XIl.png
Tada...API functions. This is only some of the ones available. If you look at the javascript file ai-prime-conn.js, you can see other functions that drive the UI, like /api/devices, which allows you to change the device name. These are the dangerous functions though, as they make changes and could cause problems.
A little more digging, into ui-support.js shows how the upload dialog is being triggered
...and another search leads me to the functions that are processing the aip files, in the following function
Now the important part....how is the checksum calculated...Well a bit more digging and I found the where the checksum was calculated. Using that for inspiration, I wrote this powershell script to calculate the correct checksum, for a given AIP file.
(If anyone wants to run this they must run it in an x86 instance of Powershell. It's to do with how I'm running the javascript code.)
Next step is to build out some functions, that will allow you to increase or decrease the intensity, of the lights. I'll probably add something to timeshift a give AIP as well. Has anyone else played around with this before? Any other functions people would want?
I've added two clowns, who proceeded to decimate my pod population and seem to be pretty happy now. I've also added a few turbos and a peppermint shrimp (we've two more to pick up tomorrow). I've also added a Tunze Nanonstream 6040, for some extra flow. Now for the obligatory photo's
As you can see I ended up buying a Hydra 26 HD...it's not off center any more.
The clownbabies (Madam Mim & Merlin....I blame my girlfriend for those names)
Slightly blurry but here is that fungia, that was in the middle of my live rock. I've extracted him
Now, onto the main event. As you can see, I caved...I was finding it hard to build out what I wanted on a small scale, for lighting...if I was building a bigger rig, I could make it work but for this it ended up working better for me, to buy off the shelf....but that won't stop me trying to tinker around with it :)
WARNING: Now, before we got any further....there be dragons...anything I'm messing with below, is for my own entertainment. You may be violating the warranty, by messing with these APIs below.
My Problem:
I've grabbed some aip files, with some sample programs, for the lights but they don't quite match what I want...I could write a script to change them to timeshift them to run earlier in the day and reduce the intensity (they're too strong from my tank, sometimes) but the problem is that there's a checksum in the file, which fails if I edit the file before uploading it.
My Goals:
Let's see if we can figure out how the checksum is being calculated.
The Analysis:
I did a bit of digging through the code, for the web ui, for my Hydra 26 HD and it lead me to notice a check for a cookie called "web_goblins" if it was true then it would add new elements to the page...turns out there's an API that I can query. A quick change in Chrome developers tools...
View attachment ai.imgur.com_43Ah2XIl.png
Tada...API functions. This is only some of the ones available. If you look at the javascript file ai-prime-conn.js, you can see other functions that drive the UI, like /api/devices, which allows you to change the device name. These are the dangerous functions though, as they make changes and could cause problems.
A little more digging, into ui-support.js shows how the upload dialog is being triggered
Code:
$("#upload").on("click", function() {
$("#share_options").hide();
$("#importRamp").trigger("click")
});
Code:
$("#importRamp").change
Code:
param(
[Parameter(Mandatory=$true)]
[String]$inputAIPFile
)
function Create-ScriptEngine()
{
param([string]$language = $null, [string]$code = $null);
if ( $language )
{
$sc = New-Object -ComObject ScriptControl;
$sc.Language = $language;
if ( $code )
{
$sc.AddCode($code);
}
$sc.CodeObject;
}
}
$jsCode =
@"
function getChecksum(l) {
var k = 0;
if (l.length == 0) {
return k
}
for (var j = 0; j < l.length; j++) {
var h = l.charCodeAt(j);
k = ((k << 5) - k) + h;
k = k & 4294967295
}
if (k < 0) {
k = ~k
}
return k
};
"@
$js = Create-ScriptEngine "JScript" $jsCode
[xml]$xml = Get-Content -Path $inputAIPFile
$colorsStr = [string]$xml.ramp.colors.OuterXml
$js.getChecksum($colorsStr)
Next step is to build out some functions, that will allow you to increase or decrease the intensity, of the lights. I'll probably add something to timeshift a give AIP as well. Has anyone else played around with this before? Any other functions people would want?