Skip to content

Commit

Permalink
Add connectability from discovery data (#750)
Browse files Browse the repository at this point in the history
* Update dependencies, set ruby version and run codegen

* Add IsConnectable support for Android and iOS

* iOS Project updates

* Set melos to fixed version

* Add tests

* Keep bledata protos number in order

---------

Co-authored-by: RutgerVromans <[email protected]>
  • Loading branch information
RtgrV and RutgerVromans authored Jun 28, 2023
1 parent 9aa9957 commit ccc0298
Show file tree
Hide file tree
Showing 47 changed files with 4,097 additions and 3,045 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feel free to open an new issue or a pull request to make this project better

This project uses melos to manage all the packages inside this repo.

Install melos: `dart pub global activate melos`
Install melos: `dart pub global activate melos 2.9.0`
Setup melos to point to the dependencies in your local folder: `melos bootstrap`

### Android
Expand Down
2 changes: 1 addition & 1 deletion bin/quality_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo 'export PATH="$PATH":"$FLUTTER_ROOT/.pub-cache/bin"' >>~/.bashrc
echo 'export PATH="$PATH":"$FLUTTER_ROOT/bin"' >>~/.bashrc
source ~/.bashrc

dart pub global activate melos
dart pub global activate melos 2.9.0

melos bootstrap
melos run analyze
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/reactive_ble_mobile/ios"

SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Protobuf: 1a37ebea1338949e9ac35a3f06e80b3f536eec8d
reactive_ble_mobile: 9ce6723d37ccf701dbffd202d487f23f5de03b4c
SwiftProtobuf: 9c85136c6ba74b0a1b84279dbf0f6db8efb714e0

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.11.2
COCOAPODS: 1.10.1
17 changes: 13 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -161,7 +161,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -207,10 +207,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -221,6 +223,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -432,7 +435,10 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand All @@ -459,7 +465,10 @@
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
12 changes: 8 additions & 4 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -22,6 +24,12 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
Expand All @@ -45,9 +53,5 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/lib/src/ui/device_detail/device_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _DeviceDetail extends StatelessWidget {
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text(device.name),
title: Text(device.name.isNotEmpty ? device.name : "Unnamed"),
bottom: const TabBar(
tabs: [
Tab(
Expand Down
12 changes: 11 additions & 1 deletion example/lib/src/ui/device_detail/device_interaction_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DeviceInteractionTab extends StatelessWidget {
_DeviceInteractionTab(
viewModel: DeviceInteractionViewModel(
deviceId: device.id,
connectableStatus: device.connectable,
connectionStatus: connectionStateUpdate.connectionState,
deviceConnector: deviceConnector,
discoverServices: () =>
Expand All @@ -39,12 +40,14 @@ class DeviceInteractionTab extends StatelessWidget {
class DeviceInteractionViewModel extends $DeviceInteractionViewModel {
const DeviceInteractionViewModel({
required this.deviceId,
required this.connectableStatus,
required this.connectionStatus,
required this.deviceConnector,
required this.discoverServices,
});

final String deviceId;
final Connectable connectableStatus;
final DeviceConnectionState connectionStatus;
final BleDeviceConnector deviceConnector;
@CustomEquality(Ignore())
Expand Down Expand Up @@ -107,7 +110,14 @@ class _DeviceInteractionTabState extends State<_DeviceInteractionTab> {
Padding(
padding: const EdgeInsetsDirectional.only(start: 16.0),
child: Text(
"Status: ${widget.viewModel.connectionStatus}",
"Connectable: ${widget.viewModel.connectableStatus}",
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsetsDirectional.only(start: 16.0),
child: Text(
"Connection: ${widget.viewModel.connectionStatus}",
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
Expand Down
20 changes: 19 additions & 1 deletion example/lib/src/ui/device_detail/device_interaction_tab.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions example/lib/src/ui/device_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,26 @@ class _DeviceListState extends State<_DeviceList> {
...widget.scannerState.discoveredDevices
.map(
(device) => ListTile(
title: Text(device.name),
subtitle: Text("${device.id}\nRSSI: ${device.rssi}"),
title: Text(
device.name.isNotEmpty ? device.name : "Unnamed",
),
subtitle: Text(
"""
${device.id}
RSSI: ${device.rssi}
${device.connectable}
""",
),
leading: const BluetoothIcon(),
onTap: () async {
widget.stopScan();
await Navigator.push<void>(
context,
MaterialPageRoute(
builder: (_) =>
DeviceDetailScreen(device: device)));
context,
MaterialPageRoute(
builder: (_) =>
DeviceDetailScreen(device: device),
),
);
},
),
)
Expand Down
4 changes: 2 additions & 2 deletions example/lib/src/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class BluetoothIcon extends StatelessWidget {

@override
Widget build(BuildContext context) => const SizedBox(
width: 64,
height: 64,
width: 32,
height: 32,
child: Align(alignment: Alignment.center, child: Icon(Icons.bluetooth)),
);
}
Expand Down
Loading

0 comments on commit ccc0298

Please sign in to comment.