commit
c266f87fc2
@ -1,16 +0,0 @@
|
||||
/*
|
||||
enum DeviceConnectionStatus { NOT_CONNECTED, CONNECTING, CONNECTED }
|
||||
enum DeviceConnectionStatus { NOT_CONNECTED, CONNECTING, CONNECTED }
|
||||
|
||||
extension DeviceConnectionStatusExtenstion on DeviceConnectionStatus {
|
||||
String get statusName {
|
||||
switch (this) {
|
||||
case DeviceConnectionStatus.NOT_CONNECTED:
|
||||
return "Not connected";
|
||||
case DeviceConnectionStatus.CONNECTING:
|
||||
return "Connecting";
|
||||
case DeviceConnectionStatus.CONNECTED:
|
||||
return "MDS connected";
|
||||
}
|
||||
}
|
||||
}*/
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
import 'package:smartfit_app_mobile/Modele/Mds/DeviceConnectionStatus.dart';
|
||||
|
||||
class Device {
|
||||
String? _address;
|
||||
String? _name;
|
||||
String? _serial;
|
||||
DeviceConnectionStatus _connectionStatus =
|
||||
DeviceConnectionStatus.NOT_CONNECTED;
|
||||
|
||||
Device(String? name, String? address) {
|
||||
_name = name;
|
||||
_address = address;
|
||||
}
|
||||
|
||||
//String? get name => _name != null ? _name : "";
|
||||
String? get name {
|
||||
if (_name == null) {
|
||||
return "";
|
||||
}
|
||||
return _name;
|
||||
}
|
||||
|
||||
//String? get address => _address != null ? _address : "";
|
||||
String? get address {
|
||||
if (_address == null) {
|
||||
return "";
|
||||
}
|
||||
return _address;
|
||||
}
|
||||
|
||||
//String? get serial => _serial != null ? _serial : "";
|
||||
String? get serial {
|
||||
if (_serial == null) {
|
||||
return "";
|
||||
}
|
||||
return _serial;
|
||||
}
|
||||
|
||||
DeviceConnectionStatus get connectionStatus => _connectionStatus;
|
||||
|
||||
void onConnecting() => _connectionStatus = DeviceConnectionStatus.CONNECTING;
|
||||
void onMdsConnected(String serial) {
|
||||
_serial = serial;
|
||||
_connectionStatus = DeviceConnectionStatus.CONNECTED;
|
||||
}
|
||||
|
||||
void onDisconnected() =>
|
||||
_connectionStatus = DeviceConnectionStatus.NOT_CONNECTED;
|
||||
|
||||
bool operator ==(o) =>
|
||||
o is Device && o._address == _address && o._name == _name;
|
||||
int get hashCode => _address.hashCode * _name.hashCode;
|
||||
}
|
||||
*/
|
@ -1,101 +0,0 @@
|
||||
|
||||
/*
|
||||
import 'dart:collection';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mdsflutter/Mds.dart';
|
||||
import 'package:smartfit_app_mobile/Modele/Mds/DeviceConnectionStatus.dart';
|
||||
import 'package:smartfit_app_mobile/Modele/Mds/device.dart';
|
||||
|
||||
// Doc - https://pub.dev/packages/mdsflutter
|
||||
//https://github.com/petri-lipponen-movesense/mdsflutter/tree/master/example/lib
|
||||
|
||||
class ManagerStateWatch extends ChangeNotifier {
|
||||
final Set<Device> _deviceList = {};
|
||||
bool _scanning = false;
|
||||
// ------------------ //
|
||||
|
||||
bool get scanning => _scanning;
|
||||
UnmodifiableListView<Device> get deviceList =>
|
||||
UnmodifiableListView(_deviceList);
|
||||
|
||||
// ------------------ //
|
||||
|
||||
void startScan() {
|
||||
// On deconnecte les devices si ils sont connecté
|
||||
_deviceList.forEach((device) {
|
||||
if (device.connectionStatus == DeviceConnectionStatus.CONNECTED) {
|
||||
disconnect(device);
|
||||
}
|
||||
});
|
||||
|
||||
// On vide la liste
|
||||
_deviceList.clear();
|
||||
notifyListeners();
|
||||
|
||||
// On lance le scan
|
||||
try {
|
||||
Mds.startScan((name, address) {
|
||||
Device device = Device(name, address);
|
||||
if (!_deviceList.contains(device)) {
|
||||
_deviceList.add(device);
|
||||
notifyListeners();
|
||||
}
|
||||
});
|
||||
_scanning = true;
|
||||
notifyListeners();
|
||||
} on PlatformException {
|
||||
_scanning = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void stopScan() {
|
||||
Mds.stopScan();
|
||||
_scanning = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void disconnect(Device device) {
|
||||
// Deconnexion matérielle
|
||||
Mds.disconnect(device.address!);
|
||||
|
||||
disconnectOnModele(device.address);
|
||||
}
|
||||
|
||||
void disconnectOnModele(String? address) {
|
||||
// Deconnexion avec l'enum
|
||||
Device foundDevice =
|
||||
_deviceList.firstWhere((element) => element.address == address);
|
||||
foundDevice.onDisconnected();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void connectToDevice(Device device) {
|
||||
// Changement de l'enum (On connecting)
|
||||
device.onConnecting();
|
||||
// Connexion matérielle
|
||||
Mds.connect(
|
||||
device.address!,
|
||||
// Connexion établi
|
||||
(serial) => _onDeviceMdsConnected(device.address, serial),
|
||||
// Connexion coupé
|
||||
() => disconnectOnModele(device.address),
|
||||
// Erreur dans la connexion
|
||||
() => _onDeviceConnectError(device.address));
|
||||
}
|
||||
|
||||
// Appeller si la connexion à réussi
|
||||
void _onDeviceMdsConnected(String? address, String serial) {
|
||||
Device foundDevice =
|
||||
_deviceList.firstWhere((element) => element.address == address);
|
||||
// On save le serial + changer l'enum en connected
|
||||
foundDevice.onMdsConnected(serial);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Appeller si une erreur survient dans la connexion
|
||||
void _onDeviceConnectError(String? address) {
|
||||
disconnectOnModele(address);
|
||||
}
|
||||
}*/
|
@ -1,88 +0,0 @@
|
||||
# This file controls Flutter-level build steps. It should not be edited.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
|
||||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||||
# which isn't available in 3.10.
|
||||
function(list_prepend LIST_NAME PREFIX)
|
||||
set(NEW_LIST "")
|
||||
foreach(element ${${LIST_NAME}})
|
||||
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||||
endforeach(element)
|
||||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# === Flutter Library ===
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"fl_basic_message_channel.h"
|
||||
"fl_binary_codec.h"
|
||||
"fl_binary_messenger.h"
|
||||
"fl_dart_project.h"
|
||||
"fl_engine.h"
|
||||
"fl_json_message_codec.h"
|
||||
"fl_json_method_codec.h"
|
||||
"fl_message_codec.h"
|
||||
"fl_method_call.h"
|
||||
"fl_method_channel.h"
|
||||
"fl_method_codec.h"
|
||||
"fl_method_response.h"
|
||||
"fl_plugin_registrar.h"
|
||||
"fl_plugin_registry.h"
|
||||
"fl_standard_message_codec.h"
|
||||
"fl_standard_method_codec.h"
|
||||
"fl_string_codec.h"
|
||||
"fl_value.h"
|
||||
"fl_view.h"
|
||||
"flutter_linux.h"
|
||||
)
|
||||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||||
target_link_libraries(flutter INTERFACE
|
||||
PkgConfig::GTK
|
||||
PkgConfig::GLIB
|
||||
PkgConfig::GIO
|
||||
)
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
)
|
@ -1,15 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <simple_animation_progress_bar/simple_animation_progress_bar_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) simple_animation_progress_bar_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SimpleAnimationProgressBarPlugin");
|
||||
simple_animation_progress_bar_plugin_register_with_registrar(simple_animation_progress_bar_registrar);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
simple_animation_progress_bar
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
@ -1,14 +0,0 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <simple_animation_progress_bar/simple_animation_progress_bar_plugin_c_api.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
SimpleAnimationProgressBarPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SimpleAnimationProgressBarPluginCApi"));
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
simple_animation_progress_bar
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
Loading…
Reference in new issue