Skip to content

Commit

Permalink
iOS should be moderated in 1-2 hours (#172)
Browse files Browse the repository at this point in the history
IOS DFU, BLE Pairing code is now displayed
  • Loading branch information
Foxushka authored Aug 31, 2023
1 parent 2e311dc commit d4a85c8
Show file tree
Hide file tree
Showing 26 changed files with 4,072 additions and 1,183 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ jobs:
with:
name: linux-debian
path: chameleonultragui/debian/packages

build-macos:
runs-on: macos-latest
defaults:
run:
working-directory: ./chameleonultragui
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Enable macOS
run: flutter config --enable-macos-desktop
- name: Install tools
run: brew install automake libtool create-dmg
- run: flutter build macos --release
18 changes: 5 additions & 13 deletions .github/workflows/publish-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
branches:
- main
workflow_dispatch:
inputs:
publish_track:
description: 'Publishing Track'
required: true
default: 'production'
type: choice
options:
- 'production'
- 'beta'
- 'alpha'
- 'internal'

jobs:
build-android:
Expand Down Expand Up @@ -85,8 +74,8 @@
fetch-depth: 100
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.10.6' # https://github.com/flutter/flutter/issues/132725
channel: 'any'
channel: 'stable'
- run: sudo chown -R $USER . && sudo chmod -R a+rwx .
- name: Enable macOS
run: flutter config --enable-macos-desktop
- name: Install tools
Expand Down Expand Up @@ -114,7 +103,9 @@
keychain initialize
keychain add-certificates
xcode-project use-profiles
sudo chown -R $USER . && sudo chmod -R a+rwx .
flutter build macos --release --build-number ${{ github.run_number }} --build-name "1.0.${{ github.run_number }}"
sudo chown -R $USER . && sudo chmod -R a+rwx .
APP_NAME=$(find $(pwd) -name "*.app")
PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg
xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg
Expand All @@ -125,6 +116,7 @@
| .common_name][0]' \
| xargs)
xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME"
sudo chown -R $USER . && sudo chmod -R a+rwx .
rm -f unsigned.pkg
app-store-connect publish --path "$PACKAGE_NAME"
while [[ -z "$BUILD_ID" ]]; do
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Chameleon Ultra GUI
A GUI for the Chameleon Ultra/Chameleon Lite written in Flutter for cross platform operation

[![Auto build](https://github.com/GameTec-live/ChameleonUltraGUI/actions/workflows/buildapp.yml/badge.svg)](https://github.com/GameTec-live/ChameleonUltraGUI/actions/workflows/buildapp.yml)
[![Auto build](https://github.com/GameTec-live/ChameleonUltraGUI/actions/workflows/build-app.yml/badge.svg)](https://github.com/GameTec-live/ChameleonUltraGUI/actions/workflows/build-app.yml)
[![Open collective](https://opencollective.com/chameleon-ultra-gui/tiers/badge.svg)](https://opencollective.com/chameleon-ultra-gui#support)

## Installation
Expand All @@ -10,7 +10,7 @@ You can download the latest builds from GitHub Actions [here](https://github.com
App available in those stores:
- Google Play: https://play.google.com/store/apps/details?id=io.chameleon.ultra
- F-Store: not yet
- App Store: https://apps.apple.com/app/chameleon-ultra-gui/id6462919364 (macOS only)
- App Store: https://apps.apple.com/app/chameleon-ultra-gui/id6462919364
- Arch Linux (AUR): https://aur.archlinux.org/packages/chameleonultragui / https://aur.archlinux.org/packages/chameleonultragui-git
- Flathub: not yet
- Chocolatey (Windows): not yet
Expand Down Expand Up @@ -39,7 +39,7 @@ Contributions are welcome, most stuff that needs to be done can either be found

## Translations

If you want to collaborate by adding your language to the application, you can do it through [our Crowdin project](https://crowdin.com/project/chameleon-ultra-gui).
If you want to collaborate by adding your language to the application, you can do it through [our Crowdin project](https://crowdin.com/project/chameleon-ultra-gui). Do not contribute files into `chameleonultragui/lib/l100n/app_*.arb`. All translations should be added only to Crowdin. If your language is missing, you can create issue and ask to enable it. "Chameleon Ultra GUI", "Chameleon" and other trademarks should not be translated.

## Screenshots
![Connect Page](/screenshots/1.png)
Expand Down
2 changes: 1 addition & 1 deletion chameleonultragui/lib/bridge/dfu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class DFUCommunicator {
for (var offset = 0; offset < firmwareBytes.length; offset += length) {
var tries = 0;
var crcBackup = crc;
for (; tries < 10; tries++) {
for (; tries < ((Platform.isIOS) ? 50 : 10); tries++) {
await createObject(
objectType, min(firmwareBytes.length - offset, length));

Expand Down
1 change: 1 addition & 0 deletions chameleonultragui/lib/connector/serial_abstract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AbstractSerial {
bool connected = false;
bool isOpen = false;
bool isDFU = false;
bool pendingConnection = false;
String portName = "None";
ConnectionType connectionType = ConnectionType.none;
dynamic messageCallback;
Expand Down
8 changes: 7 additions & 1 deletion chameleonultragui/lib/connector/serial_android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class AndroidSerial extends AbstractSerial {
@override
Future<bool> connectSpecificDevice(devicePort) async {
if (devicePort.contains(":")) {
log.d(devicePort);
return bleSerial.connectSpecificDevice(devicePort);
} else {
return mobileSerial.connectSpecificDevice(devicePort);
Expand Down Expand Up @@ -103,4 +102,11 @@ class AndroidSerial extends AbstractSerial {

@override
bool get isDFU => (bleSerial.isDFU || mobileSerial.isDFU);

@override
bool get pendingConnection => bleSerial.pendingConnection;

@override
set pendingConnection(pendingConnection) =>
{bleSerial.pendingConnection = pendingConnection};
}
45 changes: 32 additions & 13 deletions chameleonultragui/lib/connector/serial_ble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class BLESerial extends AbstractSerial {

@override
Future<List> availableDevices() async {
if (inSearch && Platform.isIOS) {
log.w("Multiple searches in one time not allowed on iOS");
if (inSearch) {
log.w("Multiple searches in one time not allowed! FIXME");
return [];
}

Expand Down Expand Up @@ -140,6 +140,7 @@ class BLESerial extends AbstractSerial {
}

await performDisconnect();
pendingConnection = true;
connection = flutterReactiveBle
.connectToAdvertisingDevice(
id: devicePort,
Expand All @@ -149,9 +150,9 @@ class BLESerial extends AbstractSerial {
.listen((connectionState) async {
log.w(connectionState);
if (connectionState.connectionState == DeviceConnectionState.connected) {
connected = true;

if (chameleonMap[devicePort]!.dfu) {
connected = true;
pendingConnection = false;
txCharacteristic = QualifiedCharacteristic(
serviceId: dfuUUID,
characteristicId: dfuControl,
Expand All @@ -167,7 +168,8 @@ class BLESerial extends AbstractSerial {
"Received unexpected data: ${bytesToHex(Uint8List.fromList(data))}");
}
}
}, onError: (dynamic error) {
}, onError: (dynamic error) async {
await performDisconnect();
log.e(error);
});

Expand All @@ -185,6 +187,7 @@ class BLESerial extends AbstractSerial {
device = chameleonMap[devicePort]!.device;

isDFU = true;
completer.complete(true);
} else {
txCharacteristic = QualifiedCharacteristic(
serviceId: nrfUUID,
Expand All @@ -201,7 +204,8 @@ class BLESerial extends AbstractSerial {
"Received unexpected data: ${bytesToHex(Uint8List.fromList(data))}");
}
}
}, onError: (dynamic error) {
}, onError: (dynamic error) async {
await performDisconnect();
log.e(error);
});

Expand All @@ -210,17 +214,31 @@ class BLESerial extends AbstractSerial {
characteristicId: uartRX,
deviceId: connectionState.deviceId);

portName = devicePort;
device = chameleonMap[devicePort]!.device;
try {
await flutterReactiveBle.writeCharacteristicWithResponse(
rxCharacteristic!,
value: Uint8List(0));

connectionType = ConnectionType.ble;
isDFU = false;
}
connected = true;
portName = devicePort;
device = chameleonMap[devicePort]!.device;

completer.complete(true);
connectionType = ConnectionType.ble;
isDFU = false;

completer.complete(true);
} catch (_) {
try {
completer.complete(false);
} catch (_) {}
}
}
} else if (connectionState.connectionState ==
DeviceConnectionState.disconnected) {
completer.complete(false);
await performDisconnect();
try {
completer.complete(false);
} catch (_) {}
}
}, onError: (Object error) {
log.e(error);
Expand All @@ -236,6 +254,7 @@ class BLESerial extends AbstractSerial {
connectionType = ConnectionType.none;
isOpen = false;
messageCallback = null;
pendingConnection = false;
if (connection != null) {
await connection!.cancel();
connected = false;
Expand Down
13 changes: 10 additions & 3 deletions chameleonultragui/lib/gui/page/connect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class ConnectPage extends StatelessWidget {
var appState = context.watch<MyAppState>(); // Get State
var localizations = AppLocalizations.of(context)!;
return FutureBuilder(
future: appState.connector.connected
? Future.value([])
: appState.connector.availableChameleons(false),
future:
(appState.connector.connected || appState.connector.pendingConnection)
? Future.value([])
: appState.connector.availableChameleons(false),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
Expand Down Expand Up @@ -114,11 +115,17 @@ class ConnectPage extends StatelessWidget {
),
);
} else {
if (chameleonDevice.type ==
ConnectionType.ble) {
appState.connector.pendingConnection = true;
appState.changesMade();
}
await appState.connector
.connectSpecificDevice(
chameleonDevice.port);
appState.communicator = ChameleonCommunicator(
port: appState.connector);
appState.connector.pendingConnection = false;
appState.changesMade();
}
},
Expand Down
6 changes: 3 additions & 3 deletions chameleonultragui/lib/gui/page/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class HomePageState extends State<HomePage> {

Future<(Icon, String, List<String>, bool)> getFutureData() async {
var appState = context.read<MyAppState>();
List<(TagType, TagType)> usedSlots;
List<(TagType, TagType)> usedSlots = [];
try {
usedSlots = await appState.communicator!.getUsedSlots();
} catch (_) {
usedSlots = [];
} catch (e) {
appState.log.e(e);
}

return (
Expand Down
42 changes: 42 additions & 0 deletions chameleonultragui/lib/gui/page/pending_connection.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:chameleonultragui/main.dart';
import 'package:flutter/material.dart';

// Localizations
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';

class PendingConnectionPage extends StatelessWidget {
const PendingConnectionPage({super.key});

@override
Widget build(BuildContext context) {
var appState = context.watch<MyAppState>();
var localizations = AppLocalizations.of(context)!;

return Scaffold(
appBar: AppBar(
title: Text(localizations.connect),
),
body: Center(
child:
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
const CircularProgressIndicator(),
const SizedBox(height: 25),
Text(
localizations.connecting_to_ble,
),
const SizedBox(height: 10),
if (!appState.connector.connected) ...[
Text(
localizations.default_ble_password,
style: const TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
Text(
localizations.connection_might_take_some_time,
style: const TextStyle(fontWeight: FontWeight.bold),
)
],
])));
}
}
Loading

0 comments on commit d4a85c8

Please sign in to comment.