Skip to content

Commit

Permalink
Formatted code with dartfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ikulikov committed Aug 4, 2021
1 parent f1bf7bd commit d0ce260
Show file tree
Hide file tree
Showing 111 changed files with 3,094 additions and 2,393 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ThingsBoard API client library for Dart developers. Provides model objects and services to communicate with ThingsBoard platform using RESTful APIs and WebSocket protocol.
Current client version is compatible with ThingsBoard version 3.3+.
Current client version is compatible with ThingsBoard starting from version 3.3.0.

## Usage

Expand Down
7 changes: 4 additions & 3 deletions example/callbacks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ Future<void> onUserLoaded() async {
print('authUser: ${tbClient.getAuthUser()}');
var currentUserDetails = await tbClient.getUserService().getUser();
print('currentUserDetails: $currentUserDetails');
await tbClient.logout(requestConfig: RequestConfig(ignoreLoading: true, ignoreErrors: true));
await tbClient.logout(
requestConfig:
RequestConfig(ignoreLoading: true, ignoreErrors: true));
exit(0);
} else {
await tbClient.login(LoginRequest('tenant@thingsboard.org', 'tenant'));
}
}
catch (e, s) {
} catch (e, s) {
print('Error: $e');
print('Stack: $s');
}
Expand Down
35 changes: 22 additions & 13 deletions example/device_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,46 @@ void main() async {

await deviceApiExample();

await tbClient.logout(requestConfig: RequestConfig(ignoreLoading: true, ignoreErrors: true));

await tbClient.logout(
requestConfig: RequestConfig(ignoreLoading: true, ignoreErrors: true));
} catch (e, s) {
print('Error: $e');
print('Stack: $s');
}
}

Future<void> deviceApiExample() async {
print('**********************************************************************');
print('* DEVICE API EXAMPLE *');
print('**********************************************************************');
print(
'**********************************************************************');
print(
'* DEVICE API EXAMPLE *');
print(
'**********************************************************************');

var deviceName = getRandomString(30);

var device = Device(deviceName, 'default');
device.additionalInfo = {'description': 'My test device!'};
var savedDevice = await tbClient.getDeviceService().saveDevice(device);
print('savedDevice: $savedDevice');
var foundDevice = await tbClient.getDeviceService().getDeviceInfo(savedDevice.id!.id!);
var foundDevice =
await tbClient.getDeviceService().getDeviceInfo(savedDevice.id!.id!);
print('foundDevice: $foundDevice');
var res = await tbClient.getAttributeService().saveEntityAttributesV2(foundDevice!.id!, AttributeScope.SHARED_SCOPE.toShortString(), {
'targetTemperature': 22.4,
'targetHumidity': 57.8
});
var res = await tbClient.getAttributeService().saveEntityAttributesV2(
foundDevice!.id!,
AttributeScope.SHARED_SCOPE.toShortString(),
{'targetTemperature': 22.4, 'targetHumidity': 57.8});
print('Save attributes result: $res');
var attributes = await tbClient.getAttributeService().getAttributesByScope(foundDevice.id!, AttributeScope.SHARED_SCOPE.toShortString(), ['targetTemperature', 'targetHumidity']);
var attributes = await tbClient.getAttributeService().getAttributesByScope(
foundDevice.id!,
AttributeScope.SHARED_SCOPE.toShortString(),
['targetTemperature', 'targetHumidity']);
print('Found device attributes: $attributes');

await tbClient.getDeviceService().deleteDevice(savedDevice.id!.id!);
foundDevice = await tbClient.getDeviceService().getDeviceInfo(savedDevice.id!.id!);
foundDevice =
await tbClient.getDeviceService().getDeviceInfo(savedDevice.id!.id!);
print('foundDevice: $foundDevice');
print('**********************************************************************');
print(
'**********************************************************************');
}
Loading

0 comments on commit d0ce260

Please sign in to comment.