io.github.joblo2213.sma.speedwire.SpeedwireCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sma.speedwire Show documentation
Show all versions of sma.speedwire Show documentation
SMA-Speedwire is an api for communicating with SMA products over Ethernet using the speedwire
interface.
It allows listening for exchanged data between your devices and logging meter readings.
package io.github.joblo2213.sma.speedwire;
import io.github.joblo2213.sma.speedwire.protocol.telegrams.*;
/**
*
* The callback that is run on any received data packets over sma speedwire.
*
* If you want to listen for specific telegrams or parse special data, check if the provided data is of a
* specific subclass of telegram.
*
* Currently implemented telegrams:
* {@link DiscoveryResponse}, {@link EnergyMeterTelegram}
*
* Example:
*
{@code
* speedwire.onData(data -> {
* if (data instanceof DiscoveryResponse) {
* //incoming data is a discovery response. Log the ip.
* System.out.println("Found device on " + data.getOrigin().getHostAddress());
* } else if (data instanceof EnergyMeterTelegram) {
* EnergyMeterTelegram emData = (EnergyMeterTelegram) data;
* //handle energy meter data
* // ...
* }
* });
* }
*/
public interface SpeedwireCallback {
/**
* method called upon received data
*
* @param data data parsed as valid telegram
*/
void onDataReceived(Telegram data);
}