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

Fixed offsets after changes in Growatt protocol #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extractData.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ private function parseInputMessage($inputmsg)
$result = (object) [];
$length = 10;
$result->deviceId = $this->getValue($msg, $start, $length);
$start += $length;
$start += $length + 20;

$length = 10;
$result->inverterId = $this->getValue($msg, $start, $length);
$start += $length;
$start += $length + 20;

$length = 5;
$result->empty = $this->getValue($msg, $start, $length);
Expand Down
12 changes: 6 additions & 6 deletions proxy.pl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
my @allowed_ips = ($config->{Proxy_allowd_ips}->[0], $config->{Proxy_allowd_ips}->[1],$config->{Proxy_allowd_ips}->[2],$config->{Proxy_allowd_ips}->[3],$config->{Proxy_allowd_ips}->[4]);

my $debug = 1;
my $incomming_inverterID = 0;
my $incoming_inverterID = 0;
my $inverter1_ID = $config->{Inverter1_ID};
my $inverter2_ID = $config->{Inverter2_ID};
my $inverter3_ID = $config->{Inverter3_ID};
Expand Down Expand Up @@ -100,12 +100,12 @@ sub client_allowed {

sub save_to_file {
my $msg = shift;
print "incomming_inverterID:", $incomming_inverterID, "\n";
print "incoming_inverterID:", $incoming_inverterID, "\n";

my $filename = '';

use feature qw(switch);
given($incomming_inverterID){
given($incoming_inverterID){
when($inverter1_ID) { $filename = $inverter1_output_filename; }
when($inverter2_ID) { $filename = $inverter2_output_filename; }
when($inverter3_ID) { $filename = $inverter3_output_filename; }
Expand Down Expand Up @@ -139,8 +139,8 @@ sub decryptMsg {
my $pos = 0;

#for (my $i=0; $i <= length($msg); $i++)
#Only first 20 karakters, that enough for the inverterID
for (my $i=0; $i <= 20; $i++)
#Only first 40 characters, that's enough for the inverterID
for (my $i=0; $i < 40; $i++)
{
my $value = ord(substr($encryptionKey, $pos++, 1));
if ($pos +1 > length($encryptionKey))
Expand Down Expand Up @@ -184,7 +184,7 @@ sub decryptMsg {
#print(substr($buffer, 0, 25), "\n");
my $tempString = decryptMsg($buffer);
#print(substr($tempString, 0, 25), "\n");
$incomming_inverterID = substr($tempString, 10, 10); #10th karakter in string, en 10 karaketers lang
$incoming_inverterID = substr($tempString, 30, 10); #10th character in string, and 10 characters long
save_to_file($buffer);
}

Expand Down