diff --git a/fhem/FHEM/lib/Device/Firmata.pm b/fhem/FHEM/lib/Device/Firmata.pm index 307ae88a6..517a706f7 100644 --- a/fhem/FHEM/lib/Device/Firmata.pm +++ b/fhem/FHEM/lib/Device/Firmata.pm @@ -15,11 +15,11 @@ Device::Firmata - Perl interface to Firmata for the arduino platform. =head1 VERSION -Version 0.50 +Version 0.56 =cut -our $VERSION = '0.55'; +our $VERSION = '0.56'; our $DEBUG = 0; diff --git a/fhem/FHEM/lib/Device/Firmata/Platform.pm b/fhem/FHEM/lib/Device/Firmata/Platform.pm index 678e330da..17e1269ee 100644 --- a/fhem/FHEM/lib/Device/Firmata/Platform.pm +++ b/fhem/FHEM/lib/Device/Firmata/Platform.pm @@ -570,6 +570,12 @@ sub sampling_interval { return $self->{io}->data_write($sampling_interval_packet); } +sub sysex_send { + my ( $self, @sysex_data ) = @_; + my $sysex_packet = $self->{protocol}->packet_sysex(@sysex_data); + return $self->{io}->data_write($sysex_packet); +} + sub i2c_write { my ($self,$address,@data) = @_; return $self->{io}->data_write($self->{protocol}->packet_i2c_request($address,0x0,@data)); diff --git a/fhem/FHEM/lib/Device/Firmata/Protocol.pm b/fhem/FHEM/lib/Device/Firmata/Protocol.pm index 72c098f2c..0e4acd3f4 100644 --- a/fhem/FHEM/lib/Device/Firmata/Protocol.pm +++ b/fhem/FHEM/lib/Device/Firmata/Protocol.pm @@ -365,6 +365,26 @@ sub message_prepare { return $packet; } +=head2 packet_sysex + +create a binary packet containing a sysex-message + +=cut + +sub packet_sysex { + + my ( $self, @sysex_data ) = @_; + + my $protocol_version = $self->{protocol_version}; + my $protocol_commands = $COMMANDS->{$protocol_version}; + + my $bytes = @sysex_data + 2; + my $packet = pack "C" x $bytes, $protocol_commands->{START_SYSEX}, + @sysex_data, + $protocol_commands->{END_SYSEX}; + return $packet; +} + =head2 packet_sysex_command create a binary packet containing a sysex-command