Skip to content

Commit

Permalink
feat: add support for custom connection port
Browse files Browse the repository at this point in the history
  • Loading branch information
dector committed Feb 16, 2024
1 parent 9e283d4 commit 091c22b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [0.0.5] - SNAPSHOT

### New
- Add ability to connect to WLED on different port.


## [0.0.4] - 07 Feb 2024

Expand Down
11 changes: 9 additions & 2 deletions lib/src/wled.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ class Wled {
/// Host or IP
final String host;

/// Connection port
final int port;

late final HttpClient _http = HttpClient();

/// Create new WLED control.
///
/// [host] - is a hostname (e.g. `localhost`)
/// or an IPv4 address (e.g. `192.168.1.123`).
Wled(this.host);
/// [port] - (optional) connection port.
Wled(
this.host, {
this.port = 80,
});

/// Turn off LED.
Future<void> turnOff() async {
Expand Down Expand Up @@ -66,7 +73,7 @@ class Wled {

Future<HttpClientResponse> _internalRequest(String params) async {
final path = '/win$params';
final req = await _http.get(host, 80, path);
final req = await _http.get(host, port, path);
final resp = await req.close();

return resp;
Expand Down

0 comments on commit 091c22b

Please sign in to comment.