Skip to content

Commit

Permalink
Merge pull request #726 from CyBear-Jinni/Changing_grpc
Browse files Browse the repository at this point in the history
Added db
  • Loading branch information
guyluz11 authored Feb 5, 2024
2 parents 3c933f7 + 506a0c4 commit 883a30a
Show file tree
Hide file tree
Showing 49 changed files with 325 additions and 470 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<application
Expand Down
1 change: 1 addition & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
17 changes: 10 additions & 7 deletions lib/domain/connections_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ abstract interface class ConnectionsService {
static ConnectionsService? _instance;

static ConnectionsService get instance {
return _instance ??= _AppConnectionService();
return _instance ??= _NoneConnectionService();
}

static ConnectionType _currentConnectionType = ConnectionType.appAsHub;
static ConnectionType _currentConnectionType = ConnectionType.none;

static void setCurrentConnectionType(ConnectionType connectionType) {
static void setCurrentConnectionType({
required String networkBssid,
required ConnectionType connectionType,
}) {
if (connectionType == _currentConnectionType) {
return;
}
Expand All @@ -52,13 +55,13 @@ abstract interface class ConnectionsService {

switch (connectionType) {
case ConnectionType.appAsHub:
_instance = _AppConnectionService();
_instance = _AppConnectionService(networkBssid);
case ConnectionType.hub:
_instance = _HubConnectionService();
_instance = _HubConnectionService(networkBssid);
case ConnectionType.remotePipes:
_instance = _RemotePipesConnectionService();
_instance = _RemotePipesConnectionService(networkBssid);
case ConnectionType.demo:
_instance = _DemoConnectionService();
_instance = _DemoConnectionService(networkBssid);
case ConnectionType.none:
_instance = _NoneConnectionService();
}
Expand Down
34 changes: 0 additions & 34 deletions lib/domain/i_local_db_repository.dart

This file was deleted.

4 changes: 4 additions & 0 deletions lib/domain/manage_network/i_manage_network_repository.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'dart:io';

import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:cybearjinni/domain/home_user/home_user_failures.dart';
import 'package:cybearjinni/domain/manage_network/manage_network_entity.dart';
import 'package:cybearjinni/domain/manage_network/manage_network_value_objects.dart';
import 'package:cybearjinni/infrastructure/core/logger.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/services.dart';
import 'package:kt_dart/collection.dart';
import 'package:location/location.dart' as location;
import 'package:network_info_plus/network_info_plus.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:wifi_iot/wifi_iot.dart';
Expand All @@ -22,6 +24,8 @@ abstract interface class IManageNetworkRepository {

static ManageNetworkEntity? manageWiFiEntity;

Future loadWifi();

Future<Either<HomeUserFailures, String?>> doesWiFiEnabled();

Stream<Either<HomeUserFailures, KtList<ManageNetworkEntity>>>
Expand Down
16 changes: 6 additions & 10 deletions lib/infrastructure/app_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:path_provider/path_provider.dart';

class AppCommands implements IPhoneCommandsD {
AppCommands() {
IPhoneCommandsD.instance = this;
}

class AppCommands extends SystemCommandsBaseClassD {
@override
Future<String> getAllEtcReleaseFilesText() {
// TODO: implement getAllEtcReleaseFilesText
Expand Down Expand Up @@ -62,7 +58,7 @@ class AppCommands implements IPhoneCommandsD {
}

@override
Future<String> getLocalDbPath(Future<String?> currentUserName) async {
Future<String> getLocalDbPath() async {
final Directory appDocDirectory = await getApplicationDocumentsDirectory();
return appDocDirectory.path;
}
Expand All @@ -86,8 +82,8 @@ class AppCommands implements IPhoneCommandsD {
}

@override
Future<String?> suspendComputer() {
// TODO: implement suspendComputer
throw UnimplementedError();
}
Future<String?> suspendComputer() async => null;

@override
Future<String?> getRaspberryPiDeviceVersion() async => null;
}
18 changes: 10 additions & 8 deletions lib/infrastructure/connection_service/app_connection_service.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
part of 'package:cybearjinni/domain/connections_service.dart';

class _AppConnectionService implements ConnectionsService {
_AppConnectionService() {
searchDevicesInstance = SearchDevices();
searchDevices();
}
_AppConnectionService(this.networkBssid);

late SearchDevices searchDevicesInstance;
String networkBssid;
SearchDevices? searchDevicesInstance;

@override
Future<HashMap<String, DeviceEntityBase>> get getEntities async =>
Expand All @@ -17,8 +15,12 @@ class _AppConnectionService implements ConnectionsService {
IcSynchronizer().getAreas();

@override
Future searchDevices() =>
searchDevicesInstance.startSearchIsolate(NetworkUtilitiesFlutter());
Future searchDevices() async =>
searchDevicesInstance = (searchDevicesInstance ?? SearchDevices())
..startSearchIsolate(
networkUtilitiesType: NetworkUtilitiesFlutter(),
systemCommands: SystemCommandsBaseClassD.instance,
);

@override
Stream<MapEntry<String, DeviceEntityBase>> watchEntities() =>
Expand All @@ -33,7 +35,7 @@ class _AppConnectionService implements ConnectionsService {
IcSynchronizer().setEntitiesState(action);

@override
Future dispose() async => searchDevicesInstance.dispose();
Future dispose() async => searchDevicesInstance?.dispose();

@override
Future setNewArea(AreaEntity area) async {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
part of 'package:cybearjinni/domain/connections_service.dart';

class _DemoConnectionService implements ConnectionsService {
_DemoConnectionService(this.networkBssid);

String networkBssid;

StreamController<MapEntry<String, DeviceEntityBase>>? entitiesStream;
StreamController<MapEntry<String, AreaEntity>>? areasStream;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
part of 'package:cybearjinni/domain/connections_service.dart';

class _HubConnectionService implements ConnectionsService {
_HubConnectionService() {
_HubConnectionService(this.networkBssid) {
if (currentEnvApp == EnvApp.prod) {
hubPort = 50055;
} else {
hubPort = 60055;
}
}

String networkBssid;

/// Port to connect to the cbj hub, will change according to the current
/// running environment
late int hubPort;

String? hubIp;
String? networkBssid;
String? networkName;

ClientChannel? channel;
Expand Down Expand Up @@ -166,7 +167,6 @@ class _HubConnectionService implements ConnectionsService {
final NetworkInfo networkInfo = NetworkInfo();
networkName = await networkInfo.getWifiName();
appDeviceIp = await networkInfo.getWifiIP();
networkBssid = await networkInfo.getWifiBSSID();
} else {
return false;
// if (deviceIpOnTheNetwork == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
part of 'package:cybearjinni/domain/connections_service.dart';

class _RemotePipesConnectionService implements ConnectionsService {
_RemotePipesConnectionService(this.networkBssid);

/// Port to connect to the cbj hub, will change according to the current
/// running environment
int hubPort = 50051;

String? address;
String? networkBssid;
String? networkName;
String networkBssid;

ClientChannel? channel;
CbjHubClient? stub;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 883a30a

Please sign in to comment.