lb_discovery 1.1.3 copy "lb_discovery: ^1.1.3" to clipboard
lb_discovery: ^1.1.3 copied to clipboard

Logbot MDNS discovery service to scan and find nearby devices

Logbot Discovery SDK for Flutter #

This is a package that provides an MDNS service to scan and find nearby IoTs.

Requirements #

Dart 2.17 or later

Installation & Usage #

Add the dependencies from pub.dev:

dependencies:
  lb_auth:
  lb_discovery:

lb_auth is always required to make authorized calls to the APIs. To use the SDK on you application see the example below:

For Android, add the following properties to your Android Manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

For iOS, add the following properties to Info.plist:

<key>NSLocalNetworkUsageDescription</key>
<string>Required to discover local network devices</string>
<key>NSBonjourServices</key>
<array>
    <string>_http._tcp</string>
</array>

To use the SDK on you application see the example below:

import 'package:lb_auth/lb_auth.dart';
import 'package:lb_discovery/lb_discovery.dart';

class Example {
  
  Future<void> run() async {
    /// Initialize Logbot SDK by logging in with Logbot Credentials
    await LogbotAuth.init(LogbotCredentials(
      username: username,
      password: password,
      clientId: clientId,
      clientSecret: clientSecret,
    ));
    /// Now you can use every API included on the SDK
    /// for example:
    await LogbotDiscovery.startDiscovery();
    List<Device> response = await LogbotDiscovery.discovery.discoverLocal();
  }
}
  • discover(): shows all devices, both locally and remote. Will also show devices that the user do not own. Requires authentication.
  • discover(DiscoveryFilter.OWNED): shows all devices that the user owns, both locally and remote. Requires authentication.
  • discover(DiscoveryFilter.NOT_CONFIG): shows devices that are not configured. These devices will surely be on the local network. No authentication required. same as discoverLocal(DiscoveryFilter.NOT_CONFIG).
  • discoverLocal(): shows all devices in the local network, included not configured. No authentication required.
  • discoverLocal(DiscoveryFilter.OWNED): shows only local devices that the user owns, skipping not configured devices. Requires authentication.
  • discoverLocal(DiscoveryFilter.NOT_CONFIG): shows only local devices that are not configured. No authentication required.
  • discoverRemote(): shows only the remote devices that the user owns and registered to the platform. Requires authentication.

Note: owned flag should not be considered when using discoverLocal() API.

Tests #

To run all tests:

flutter test

Documentation for API Endpoints #

Class Method Description
DiscoveryApi discover GET /discovery
DiscoveryApi discoverDevice GET /discovery/{deviceId}
DiscoveryApi discoverLocal GET /discovery/local
DiscoveryApi discoverRemote GET /discovery/remote

Documentation For Models #

Author #

Logbot SRL info@logbot.cloud

1
likes
50
points
91
downloads

Publisher

verified publisherlogbot.cloud

Weekly Downloads

Logbot MDNS discovery service to scan and find nearby devices

Homepage

Documentation

Documentation

License

BSD-3-Clause (license)

Dependencies

collection, connectivity_plus, http, intl, lb_auth, lb_commons, lb_core, meta, multicast_dns, mutex, nsd, plugin_platform_interface

More

Packages that depend on lb_discovery