Skip to content

Commit

Permalink
Release 1.2.0 (#120)
Browse files Browse the repository at this point in the history
* Release 1.2.0

* Fix analysis issues

* Secure link, fix formatting

* Fix test
  • Loading branch information
mikolak committed Dec 4, 2020
1 parent 26634bf commit 6c78b00
Show file tree
Hide file tree
Showing 59 changed files with 832 additions and 900 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BleManager bleManager = BleManager();
bleManager.createClient(); //this creates an instance of native BLE
```
### Defining simple simulated peripheral
The following peripheral is based on [Texas Instruments CC2541 SensorTag](http://www.ti.com/tool/CC2541DK-SENSOR).
The following peripheral is based on [Texas Instruments CC2541 SensorTag](https://www.ti.com/tool/CC2541DK-SENSOR).
To keep the example clearer, only IR temperature service is simulated.
```dart
class SensorTag extends SimulatedPeripheral {
Expand Down Expand Up @@ -77,7 +77,7 @@ class SensorTag extends SimulatedPeripheral {

This creates a peripheral that advertises every 800 milliseconds while peripheral scan is on,
waits for 200 milliseconds after receiving connection request before agreeing to connect and has a single service
with three characteristics according to [SensorTag documentation](http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf).
with three characteristics according to [SensorTag documentation](https://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf).

The _convenienceName_ fields are optional and not used by the blemulator itself, but allow you to name created objects for better maintainability.

Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:pedantic/analysis_options.1.9.0.yaml
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.polidea.blemulator'
version '1.1.2'
version '1.2.0'

buildscript {
repositories {
Expand Down Expand Up @@ -35,5 +35,5 @@ android {
}

dependencies {
implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.5'
implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.7'
}
79 changes: 15 additions & 64 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,32 @@ project 'Runner', {
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
generated_key_values
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

# Flutter Pod

copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end

# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'

# Plugin Pods

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
flutter_additional_ios_build_settings(target)
end
end
12 changes: 9 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,18 @@
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/MultiplatformBleAdapter/MultiplatformBleAdapter.framework",
"${BUILT_PRODUCTS_DIR}/blemulator/blemulator.framework",
"${BUILT_PRODUCTS_DIR}/flutter_ble_lib/flutter_ble_lib.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MultiplatformBleAdapter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/blemulator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_ble_lib.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -310,7 +319,6 @@
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -390,7 +398,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -446,7 +453,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down
16 changes: 8 additions & 8 deletions example/lib/adapter/ble_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BleAdapter {

Stream<BlePeripheral> get blePeripherals => _blePeripheralsController.stream;

Map<String, Peripheral> _scannedPeripherals = Map();
final Map<String, Peripheral> _scannedPeripherals = {};

factory BleAdapter(BleManager bleManager, Blemulator blemulator) {
if (_instance == null) {
Expand Down Expand Up @@ -81,9 +81,9 @@ class BleAdapter {

void _setupSimulation() {
_blemulator.addSimulatedPeripheral(SensorTag());
_blemulator.addSimulatedPeripheral(SensorTag(id: "different id"));
_blemulator.addSimulatedPeripheral(SensorTag(id: 'different id'));
_blemulator
.addSimulatedPeripheral(SensorTag(id: "yet another different id"));
.addSimulatedPeripheral(SensorTag(id: 'yet another different id'));
_blemulator.addSimulatedPeripheral(GenericPeripheral());
_blemulator.simulate();
}
Expand All @@ -95,12 +95,12 @@ class BleAdapter {
await _scannedPeripherals[peripheralId]
.discoverAllServicesAndCharacteristics();

List<BleService> bleServices = [];
for (Service service
var bleServices = <BleService>[];
for (var service
in await _scannedPeripherals[peripheralId].services()) {
List<Characteristic> serviceCharacteristics =
var serviceCharacteristics =
await service.characteristics();
List<BleCharacteristic> bleCharacteristics = serviceCharacteristics
var bleCharacteristics = serviceCharacteristics
.map(
(characteristic) =>
BleCharacteristic.fromCharacteristic(characteristic),
Expand All @@ -110,7 +110,7 @@ class BleAdapter {
}

// TODO remove when connectivity handling is implemented
_scannedPeripherals[peripheralId].disconnectOrCancelConnection();
await _scannedPeripherals[peripheralId].disconnectOrCancelConnection();

return bleServices;
}
Expand Down
16 changes: 8 additions & 8 deletions example/lib/device_details/device_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
Fimber.d("didChangeDependencies");
Fimber.d('didChangeDependencies');
if (_deviceDetailsBloc == null) {
_deviceDetailsBloc = DeviceDetailsBlocProvider.of(context);
if (_shouldRunOnResume) {
Expand All @@ -33,27 +33,27 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
}

void _onResume() {
Fimber.d("onResume");
Fimber.d('onResume');
_deviceDetailsBloc.init();
_appStateSubscription =
_deviceDetailsBloc.disconnectedDevice.listen((bleDevice) async {
Fimber.d("navigate to details");
Fimber.d('navigate to details');
_onPause();
Navigator.pop(context);
_shouldRunOnResume = true;
Fimber.d("back from details");
Fimber.d('back from details');
});
}

void _onPause() {
Fimber.d("onPause");
Fimber.d('onPause');
_appStateSubscription.cancel();
_deviceDetailsBloc.dispose();
}

@override
void dispose() {
Fimber.d("Dispose DeviceListScreenState");
Fimber.d('Dispose DeviceListScreenState');
_onPause();
super.dispose();
}
Expand All @@ -74,8 +74,8 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
title: Text('Device Details'),
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.autorenew), text: "Automatic",),
Tab(icon: Icon(Icons.settings), text: "Manual",),
Tab(icon: Icon(Icons.autorenew), text: 'Automatic',),
Tab(icon: Icon(Icons.settings), text: 'Manual',),
],
),
),
Expand Down
Loading

0 comments on commit 6c78b00

Please sign in to comment.