Skip to content

shaxxx/EnigmaWeb.Dart

Repository files navigation

EnigmaWeb

This library is conversion of EnigmaWeb to Dart language. Works with both Enigma1 and Enigma2 web interfaces.

First thing to do is to setup profile information

var profile = Profile(
  address: "192.168.0.2",
  httpPort: 80,
  enigma: EnigmaType.enigma2,
  username: "root",
  password: "password",
  name: "My receiver",
  streaming: false,
  id: "1",
);

Execute command

All available web commands are implemented, just execute command and read response from object model, ie.

    //initialize parser to parse response to read current service from receiver
    var currentServiceResponseParser = GetCurrentServiceParser();
    //initialize http client implementation to send HTTP requests to receiver
    var webRequester = WebRequester(Logger.root);
    //initialize get current service command object
    var command = GetCurrentServiceCommand(currentServiceResponseParser, webRequester);
    //execute command and get typed result
    GetCurrentServiceResponse response = await command.executeAsync(profile);
    //use result
    print(response.currentService);
    print(response.responseDuration);

    //some commands dont need parsing (IE. we're not interested in result, just if command was successfull)
    //for that we use UnparsedParser<TCommand>, for example WakeUp command to wake up Enigma
    var noParsing = UnparsedParser<WakeUpCommand>();
    // perform WakeUp command, and just wait for it to finish
    await WakeUpCommand(noParsing, requester).executeAsync(profile);

About

Attempt to create unified API to control Enigma1 & Enigma2 web interfaces in Dart language

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages