react-native-flic2 0.3.25 → 2.0.0-alpha.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Flic2.podspec +22 -0
- package/{LICENSE.md → LICENSE} +1 -1
- package/README.md +17 -523
- package/android/build.gradle +64 -132
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +17 -29
- package/android/src/main/java/com/flic2/Flic2ButtonListener.kt +132 -0
- package/android/src/main/java/com/flic2/Flic2Converter.kt +103 -0
- package/android/src/main/java/com/flic2/Flic2Module.kt +480 -0
- package/android/src/main/java/com/flic2/Flic2Package.kt +33 -0
- package/android/src/main/java/com/flic2/Flic2Service.kt +112 -0
- package/ios/Flic2.h +9 -4
- package/ios/Flic2.mm +610 -0
- package/ios/flic2lib.framework/Headers/FLICButton.h +1 -1
- package/ios/flic2lib.framework/Headers/FLICManager.h +1 -1
- package/ios/flic2lib.framework/Info.plist +0 -0
- package/ios/flic2lib.framework/Modules/module.modulemap +1 -1
- package/ios/flic2lib.framework/flic2lib +0 -0
- package/lib/module/NativeFlic2.js +14 -0
- package/lib/module/NativeFlic2.js.map +1 -0
- package/lib/module/index.js +91 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeFlic2.d.ts +119 -0
- package/lib/typescript/src/NativeFlic2.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +81 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +132 -19
- package/src/NativeFlic2.ts +157 -0
- package/src/index.tsx +159 -0
- package/.editorconfig +0 -7
- package/.gitattributes +0 -1
- package/.idea/codeStyles/Project.xml +0 -116
- package/.idea/modules.xml +0 -8
- package/.idea/react-native-flic2.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -140
- package/android/.classpath +0 -6
- package/android/.gradle/5.4.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/5.4.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/5.4.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/5.4.1/fileContent/fileContent.lock +0 -0
- package/android/.gradle/5.4.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/5.4.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/5.4.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/5.4.1/gc.properties +0 -0
- package/android/.gradle/5.4.1/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/5.4.1/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/5.4.1/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/5.4.1/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/caches/build_file_checksums.ser +0 -0
- package/android/.idea/codeStyles/Project.xml +0 -116
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/libraries/Gradle__android_arch_core_common_1_1_1_jar.xml +0 -11
- package/android/.idea/libraries/Gradle__android_arch_core_runtime_1_1_1_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_common_1_1_1_jar.xml +0 -11
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_livedata_1_1_1_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_livedata_core_1_1_1_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_runtime_1_1_1_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__android_arch_lifecycle_viewmodel_1_1_1_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_appcompat_v7_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_asynclayoutinflater_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_collections_28_0_0_jar.xml +0 -9
- package/android/.idea/libraries/Gradle__com_android_support_coordinatorlayout_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_cursoradapter_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_customview_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_documentfile_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_drawerlayout_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_interpolator_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_loader_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_localbroadcastmanager_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_print_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_slidingpanelayout_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_support_annotations_28_0_0_jar.xml +0 -9
- package/android/.idea/libraries/Gradle__com_android_support_support_compat_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_support_core_ui_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_support_core_utils_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_support_fragment_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_support_vector_drawable_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_swiperefreshlayout_28_0_0_aar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_android_support_versionedparcelable_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_android_support_viewpager_28_0_0_aar.xml +0 -10
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_1_10_0_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_1_10_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_1_10_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_1_10_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_1_10_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_1_10_0_aar.xml +0 -12
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2_jar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_59_10_aar.xml +0 -17
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_6_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2_jar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_1_jar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_1_jar.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0_jar.xml +0 -13
- package/android/.idea/libraries/Gradle__io_flic_flic2lib_android_1_1_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml +0 -13
- package/android/.idea/misc.xml +0 -14
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/runConfigurations.xml +0 -12
- package/android/.idea/vcs.xml +0 -6
- package/android/.idea/workspace.xml +0 -348
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/README.md +0 -14
- package/android/android.iml +0 -139
- package/android/build/generated/source/buildConfig/debug/nl/xguard/flic2/BuildConfig.java +0 -13
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -46
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -15
- package/android/build/intermediates/incremental/packageDebugResources/merged.dir/values/values.xml +0 -4
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -46
- package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
- package/android/build/intermediates/packaged_res/debug/drawable/ic_launcher_background.xml +0 -74
- package/android/build/intermediates/packaged_res/debug/drawable-v24/ic_launcher_foreground.xml +0 -34
- package/android/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/android/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
- package/android/build/intermediates/packaged_res/debug/mipmap-hdpi-v4/ic_launcher.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-hdpi-v4/ic_launcher_round.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-mdpi-v4/ic_launcher.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-mdpi-v4/ic_launcher_round.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xhdpi-v4/ic_launcher.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xhdpi-v4/ic_launcher_round.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xxhdpi-v4/ic_launcher.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xxhdpi-v4/ic_launcher_round.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xxxhdpi-v4/ic_launcher.png +0 -0
- package/android/build/intermediates/packaged_res/debug/mipmap-xxxhdpi-v4/ic_launcher_round.png +0 -0
- package/android/build/intermediates/packaged_res/debug/values/values.xml +0 -4
- package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -989
- package/android/build/intermediates/symbols/debug/R.txt +0 -1302
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -95
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradlew +0 -172
- package/android/gradlew.bat +0 -84
- package/android/local.properties +0 -8
- package/android/src/main/ic_launcher-web.png +0 -0
- package/android/src/main/java/nl/xguard/flic2/Flic2.java +0 -213
- package/android/src/main/java/nl/xguard/flic2/Flic2Package.java +0 -28
- package/android/src/main/java/nl/xguard/flic2/communication/IReactEvent.java +0 -15
- package/android/src/main/java/nl/xguard/flic2/communication/NullReactEvent.java +0 -47
- package/android/src/main/java/nl/xguard/flic2/communication/ReactEvent.java +0 -230
- package/android/src/main/java/nl/xguard/flic2/model/IReactFlic2Manager.java +0 -27
- package/android/src/main/java/nl/xguard/flic2/model/NullReactFlic2Manager.java +0 -70
- package/android/src/main/java/nl/xguard/flic2/model/ReactAndroidHandler.java +0 -33
- package/android/src/main/java/nl/xguard/flic2/model/ReactFlic2ButtonListener.java +0 -106
- package/android/src/main/java/nl/xguard/flic2/model/ReactFlic2Manager.java +0 -168
- package/android/src/main/java/nl/xguard/flic2/model/ReactFlic2ScanCallback.java +0 -48
- package/android/src/main/java/nl/xguard/flic2/model/ReactLogger.java +0 -14
- package/android/src/main/java/nl/xguard/flic2/service/Flic2Service.java +0 -200
- package/android/src/main/java/nl/xguard/flic2/service/Flic2ServiceConnection.java +0 -41
- package/android/src/main/java/nl/xguard/flic2/service/IFlic2Service.java +0 -13
- package/android/src/main/java/nl/xguard/flic2/sharedpreferences/flic2SharedPreferences.java +0 -35
- package/android/src/main/java/nl/xguard/flic2/util/ActivityUtil.java +0 -29
- package/android/src/main/java/nl/xguard/flic2/util/Consumer.java +0 -12
- package/android/src/main/res/drawable/ic_launcher_background.xml +0 -74
- package/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -34
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
- package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/src/main/res/values/ids.xml +0 -5
- package/build/generated/source/buildConfig/debug/com/flic2/BuildConfig.java +0 -13
- package/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -46
- package/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output.json +0 -1
- package/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/build/intermediates/incremental/debug-mergeJniLibs/merge-state +0 -0
- package/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -15
- package/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
- package/build/intermediates/intermediate-jars/debug/classes.jar +0 -0
- package/build/intermediates/intermediate-jars/debug/res.jar +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/BuildConfig.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/Flic2Module$1.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/Flic2Module.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/Flic2Package.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/callback/flic2ButtonCallback.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/communication/ReactEvent.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/service/Flic2Service$BootUpReceiver.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/service/Flic2Service$UpdateReceiver.class +0 -0
- package/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/flic2/service/Flic2Service.class +0 -0
- package/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -46
- package/build/intermediates/merged_manifests/debug/output.json +0 -1
- package/build/intermediates/packaged-classes/debug/classes.jar +0 -0
- package/build/intermediates/packaged_res/debug/drawable/ic_launcher_background.xml +0 -74
- package/build/intermediates/packaged_res/debug/drawable-v24/ic_launcher_foreground.xml +0 -34
- package/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/build/intermediates/packaged_res/debug/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
- package/build/intermediates/packaged_res/debug/mipmap-hdpi-v4/ic_launcher.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-hdpi-v4/ic_launcher_round.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-mdpi-v4/ic_launcher.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-mdpi-v4/ic_launcher_round.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xhdpi-v4/ic_launcher.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xhdpi-v4/ic_launcher_round.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xxhdpi-v4/ic_launcher.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xxhdpi-v4/ic_launcher_round.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xxxhdpi-v4/ic_launcher.png +0 -0
- package/build/intermediates/packaged_res/debug/mipmap-xxxhdpi-v4/ic_launcher_round.png +0 -0
- package/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -1290
- package/build/intermediates/symbols/debug/R.txt +0 -1764
- package/build/intermediates/transforms/mergeJavaRes/debug/0.jar +0 -0
- package/build/intermediates/transforms/mergeJavaRes/debug/__content__.json +0 -1
- package/build/intermediates/transforms/mergeJniLibs/debug/__content__.json +0 -1
- package/build/intermediates/transforms/stripDebugSymbol/debug/__content__.json +0 -1
- package/build/outputs/aar/react-native-flic2-debug.aar +0 -0
- package/build/outputs/logs/manifest-merger-debug-report.txt +0 -95
- package/flic2Button.js +0 -170
- package/index.js +0 -430
- package/ios/Flic2.m +0 -611
- package/ios/Flic2.xcodeproj/project.pbxproj +0 -320
- package/ios/Flic2.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Flic2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Flic2.xcodeproj/project.xcworkspace/xcuserdata/wesdewitte.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Flic2.xcodeproj/xcshareddata/xcschemes/Flic2.xcscheme +0 -66
- package/ios/Flic2.xcodeproj/xcuserdata/wesdewitte.xcuserdatad/xcschemes/xcschememanagement.plist +0 -22
- package/ios/Flic2.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/Flic2.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Flic2.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +0 -5
- package/ios/Flic2.xcworkspace/xcuserdata/wesdewitte.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Flic2.xcworkspace/xcuserdata/wesdewitte.xcuserdatad/WorkspaceSettings.xcsettings +0 -14
- package/react-native-flic2.podspec +0 -26
package/index.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
// get the native module
|
|
2
|
-
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
3
|
-
|
|
4
|
-
// event emitter
|
|
5
|
-
import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';
|
|
6
|
-
|
|
7
|
-
// local imports
|
|
8
|
-
import Flic2Button from './flic2Button.js';
|
|
9
|
-
|
|
10
|
-
// we only care about flic 2 here
|
|
11
|
-
const Flic2Module = NativeModules.Flic2;
|
|
12
|
-
|
|
13
|
-
// constants
|
|
14
|
-
const SCAN_RESULT_SUCCESS = 0;
|
|
15
|
-
const SCAN_RESULT_ERROR_ALREADY_RUNNING = 1;
|
|
16
|
-
const SCAN_RESULT_ERROR_BLUETOOTH_NOT_ACTIVATED = 2;
|
|
17
|
-
const SCAN_RESULT_ERROR_UNKNOWN = 3;
|
|
18
|
-
const SCAN_RESULT_ERROR_NO_PUBLIC_BUTTON_DISCOVERED = 4;
|
|
19
|
-
const SCAN_RESULT_ERROR_ALREADY_CONNECTED_TO_ANOTHER_DEVICE = 5;
|
|
20
|
-
const SCAN_RESULT_ERROR_CONNECTION_TIMEOUT = 6;
|
|
21
|
-
const SCAN_RESULT_ERROR_INVALID_VERIFIER = 7;
|
|
22
|
-
const SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING = 8;
|
|
23
|
-
const SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_USER_CANCELED = 9;
|
|
24
|
-
const SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_UNKNOWN_REASON = 10;
|
|
25
|
-
const SCAN_RESULT_ERROR_APP_CREDENTIALS_DONT_MATCH = 11;
|
|
26
|
-
const SCAN_RESULT_ERROR_USER_CANCELED = 12;
|
|
27
|
-
const SCAN_RESULT_ERROR_INVALID_BLUETOOTH_ADDRESS = 13;
|
|
28
|
-
const SCAN_RESULT_ERROR_GENUINE_CHECK_FAILED = 14;
|
|
29
|
-
const SCAN_RESULT_ERROR_TOO_MANY_APPS = 15;
|
|
30
|
-
const SCAN_RESULT_ERROR_COULD_NOT_SET_BLUETOOTH_NOTIFY = 16;
|
|
31
|
-
const SCAN_RESULT_ERROR_COULD_NOT_DISCOVER_BLUETOOTH_SERVICES = 17;
|
|
32
|
-
const SCAN_RESULT_ERROR_BUTTON_DISCONNECTED_DURING_VERIFICATION = 18;
|
|
33
|
-
const SCAN_RESULT_ERROR_FAILED_TO_ESTABLISH = 19;
|
|
34
|
-
const SCAN_RESULT_ERROR_CONNECTION_LIMIT_REACHED = 20;
|
|
35
|
-
const SCAN_RESULT_ERROR_NOT_IN_PUBLIC_MODE = 21;
|
|
36
|
-
|
|
37
|
-
const BUTTON_TRIGGER_MODE_CLICK_AND_HOLD = 0;
|
|
38
|
-
const BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK = 1;
|
|
39
|
-
const BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK_AND_HOLD = 2;
|
|
40
|
-
const BUTTON_TRIGGER_MODE_CLICK = 3;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* React Native Flic 2
|
|
44
|
-
* Exposes the Flic2Module functions to the React Native context.
|
|
45
|
-
*
|
|
46
|
-
* @version 1.0.0
|
|
47
|
-
*/
|
|
48
|
-
class Flic2 extends EventEmitter {
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Constructor.
|
|
52
|
-
*
|
|
53
|
-
* @class
|
|
54
|
-
* @version 1.0.0
|
|
55
|
-
*/
|
|
56
|
-
constructor() {
|
|
57
|
-
|
|
58
|
-
// extended class initialisation
|
|
59
|
-
super();
|
|
60
|
-
|
|
61
|
-
this.isFlic2ManagerInitialized = false;
|
|
62
|
-
|
|
63
|
-
// define constants
|
|
64
|
-
this.constants = {
|
|
65
|
-
SCAN_RESULT_SUCCESS: SCAN_RESULT_SUCCESS,
|
|
66
|
-
SCAN_RESULT_ERROR_ALREADY_RUNNING: SCAN_RESULT_ERROR_ALREADY_RUNNING,
|
|
67
|
-
SCAN_RESULT_ERROR_BLUETOOTH_NOT_ACTIVATED: SCAN_RESULT_ERROR_BLUETOOTH_NOT_ACTIVATED,
|
|
68
|
-
SCAN_RESULT_ERROR_UNKNOWN: SCAN_RESULT_ERROR_UNKNOWN,
|
|
69
|
-
SCAN_RESULT_ERROR_NO_PUBLIC_BUTTON_DISCOVERED: SCAN_RESULT_ERROR_NO_PUBLIC_BUTTON_DISCOVERED,
|
|
70
|
-
SCAN_RESULT_ERROR_ALREADY_CONNECTED_TO_ANOTHER_DEVICE: SCAN_RESULT_ERROR_ALREADY_CONNECTED_TO_ANOTHER_DEVICE,
|
|
71
|
-
SCAN_RESULT_ERROR_CONNECTION_TIMEOUT: SCAN_RESULT_ERROR_CONNECTION_TIMEOUT,
|
|
72
|
-
SCAN_RESULT_ERROR_INVALID_VERIFIER: SCAN_RESULT_ERROR_INVALID_VERIFIER,
|
|
73
|
-
SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING: SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_PREVIOUS_PAIRING_ALREADY_EXISTING,
|
|
74
|
-
SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_USER_CANCELED: SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_USER_CANCELED,
|
|
75
|
-
SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_UNKNOWN_REASON: SCAN_RESULT_ERROR_BLE_PAIRING_FAILED_UNKNOWN_REASON,
|
|
76
|
-
SCAN_RESULT_ERROR_APP_CREDENTIALS_DONT_MATCH: SCAN_RESULT_ERROR_APP_CREDENTIALS_DONT_MATCH,
|
|
77
|
-
SCAN_RESULT_ERROR_USER_CANCELED: SCAN_RESULT_ERROR_USER_CANCELED,
|
|
78
|
-
SCAN_RESULT_ERROR_INVALID_BLUETOOTH_ADDRESS: SCAN_RESULT_ERROR_INVALID_BLUETOOTH_ADDRESS,
|
|
79
|
-
SCAN_RESULT_ERROR_GENUINE_CHECK_FAILED: SCAN_RESULT_ERROR_GENUINE_CHECK_FAILED,
|
|
80
|
-
SCAN_RESULT_ERROR_TOO_MANY_APPS: SCAN_RESULT_ERROR_TOO_MANY_APPS,
|
|
81
|
-
SCAN_RESULT_ERROR_COULD_NOT_SET_BLUETOOTH_NOTIFY: SCAN_RESULT_ERROR_COULD_NOT_SET_BLUETOOTH_NOTIFY,
|
|
82
|
-
SCAN_RESULT_ERROR_COULD_NOT_DISCOVER_BLUETOOTH_SERVICES: SCAN_RESULT_ERROR_COULD_NOT_DISCOVER_BLUETOOTH_SERVICES,
|
|
83
|
-
SCAN_RESULT_ERROR_BUTTON_DISCONNECTED_DURING_VERIFICATION: SCAN_RESULT_ERROR_BUTTON_DISCONNECTED_DURING_VERIFICATION,
|
|
84
|
-
SCAN_RESULT_ERROR_FAILED_TO_ESTABLISH: SCAN_RESULT_ERROR_FAILED_TO_ESTABLISH,
|
|
85
|
-
SCAN_RESULT_ERROR_CONNECTION_LIMIT_REACHED: SCAN_RESULT_ERROR_CONNECTION_LIMIT_REACHED,
|
|
86
|
-
SCAN_RESULT_ERROR_NOT_IN_PUBLIC_MODE: SCAN_RESULT_ERROR_NOT_IN_PUBLIC_MODE,
|
|
87
|
-
BUTTON_TRIGGER_MODE_CLICK_AND_HOLD: BUTTON_TRIGGER_MODE_CLICK_AND_HOLD,
|
|
88
|
-
BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK: BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK,
|
|
89
|
-
BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK_AND_HOLD: BUTTON_TRIGGER_MODE_CLICK_AND_DOUBLE_CLICK_AND_HOLD,
|
|
90
|
-
BUTTON_TRIGGER_MODE_CLICK: BUTTON_TRIGGER_MODE_CLICK,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// proxy
|
|
94
|
-
this.onScanResultFunction = this.onScanResult.bind(this);
|
|
95
|
-
this.didReceiveButtonEventFunction = this.didReceiveButtonEvent.bind(this);
|
|
96
|
-
this.onInitializedFunction = this.onInitialized.bind(this);
|
|
97
|
-
|
|
98
|
-
// listen to events
|
|
99
|
-
this.nativeEvents = new NativeEventEmitter(Flic2Module);
|
|
100
|
-
|
|
101
|
-
// button click events
|
|
102
|
-
this.nativeEvents.addListener('didReceiveButtonEvent', this.didReceiveButtonEventFunction);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.registerInitializedCallback();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// known buttons
|
|
109
|
-
this.knownButtons = {};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Start up the flic module
|
|
114
|
-
*/
|
|
115
|
-
start() {
|
|
116
|
-
// start the native context
|
|
117
|
-
Flic2Module.startup();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
registerInitializedCallback(){
|
|
121
|
-
if(Platform.OS === 'android') {
|
|
122
|
-
Flic2Module.registerFlic2ManagerInitializedCallback( (result) => {
|
|
123
|
-
if(result) {
|
|
124
|
-
this.onInitialized();
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
} else {
|
|
128
|
-
this.nativeEvents.addListener('managerInitialized', this.onInitializedFunction);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
onInitialized() {
|
|
133
|
-
this.isFlic2ManagerInitialized = true;
|
|
134
|
-
this.emit('managerInitialized');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
isInitialized() {
|
|
138
|
-
return this.isFlic2ManagerInitialized;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get a Flic2Button object by UUID.
|
|
144
|
-
*
|
|
145
|
-
* @version 1.0.0
|
|
146
|
-
* @returns {Promise} Promise represents the Flic2Button object.
|
|
147
|
-
*/
|
|
148
|
-
getButton(uuid) {
|
|
149
|
-
return new Promise(async (resolve, reject) => {
|
|
150
|
-
|
|
151
|
-
// first get all the buttons
|
|
152
|
-
const buttons = await this.getButtons();
|
|
153
|
-
|
|
154
|
-
// since the list of Flic buttons will never be huge
|
|
155
|
-
// we do not bother with not using a loop here to find the button
|
|
156
|
-
for (const button of buttons) {
|
|
157
|
-
|
|
158
|
-
// check
|
|
159
|
-
if (button.getUuid() === uuid) {
|
|
160
|
-
|
|
161
|
-
return resolve(button);
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Get an array of Flic2 Buttons.
|
|
172
|
-
*
|
|
173
|
-
* @version 1.0.0
|
|
174
|
-
* @returns {Promise} Promise represents an array of Flic2Button objects.
|
|
175
|
-
*/
|
|
176
|
-
getButtons() {
|
|
177
|
-
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
|
|
180
|
-
// proxy
|
|
181
|
-
Flic2Module.getButtons((buttons) => {
|
|
182
|
-
|
|
183
|
-
// mutate
|
|
184
|
-
const exportButtons = [];
|
|
185
|
-
for (const button of buttons){
|
|
186
|
-
|
|
187
|
-
// button uuid
|
|
188
|
-
const buttonUuid = button.uuid;
|
|
189
|
-
|
|
190
|
-
// check if we have the button object in memory
|
|
191
|
-
if (typeof this.knownButtons[buttonUuid] !== 'undefined'){
|
|
192
|
-
|
|
193
|
-
// update
|
|
194
|
-
const knownButton = this.knownButtons[buttonUuid];
|
|
195
|
-
|
|
196
|
-
knownButton.setData(button);
|
|
197
|
-
|
|
198
|
-
if (button.batteryLevelIsOk === false) {
|
|
199
|
-
// emit
|
|
200
|
-
this.emit('criticalBattery');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// add
|
|
204
|
-
exportButtons.push(knownButton);
|
|
205
|
-
|
|
206
|
-
} else {
|
|
207
|
-
|
|
208
|
-
// create it
|
|
209
|
-
this.knownButtons[buttonUuid] = new Flic2Button(button);
|
|
210
|
-
|
|
211
|
-
if (button.batteryLevelIsOk === false) {
|
|
212
|
-
// emit
|
|
213
|
-
this.emit('criticalBattery');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// add
|
|
217
|
-
exportButtons.push(this.knownButtons[buttonUuid]);
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// export all known buttons
|
|
225
|
-
return resolve(exportButtons);
|
|
226
|
-
|
|
227
|
-
}, reject);
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Starts a scan to find a button.
|
|
234
|
-
*
|
|
235
|
-
* @version 1.0.0
|
|
236
|
-
* @returns {boolean} Returns boolean true when finished.
|
|
237
|
-
*/
|
|
238
|
-
startScan() {
|
|
239
|
-
|
|
240
|
-
// listen for scanResult
|
|
241
|
-
this.nativeEvents.addListener('scanResult', this.onScanResultFunction);
|
|
242
|
-
|
|
243
|
-
// start the scan
|
|
244
|
-
Flic2Module.startScan();
|
|
245
|
-
|
|
246
|
-
// done
|
|
247
|
-
return true;
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Stops the scan and removes the scanResult listener.
|
|
253
|
-
*
|
|
254
|
-
* @version 1.0.0
|
|
255
|
-
* @returns {boolean} Returns boolean true when finished.
|
|
256
|
-
*/
|
|
257
|
-
stopScan() {
|
|
258
|
-
|
|
259
|
-
// listen for scanResult
|
|
260
|
-
this.nativeEvents.removeListener('scanResult', this.onScanResultFunction);
|
|
261
|
-
|
|
262
|
-
// start the scan
|
|
263
|
-
Flic2Module.stopScan();
|
|
264
|
-
|
|
265
|
-
// done
|
|
266
|
-
return true;
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Event: scan result.
|
|
272
|
-
* Emits a scanResult event to the react native application with a Flic2Button object attached.
|
|
273
|
-
*
|
|
274
|
-
* @version 1.0.0
|
|
275
|
-
*/
|
|
276
|
-
onScanResult({ event, error, result, button }){
|
|
277
|
-
|
|
278
|
-
// check if error
|
|
279
|
-
let ButtonObject;
|
|
280
|
-
if (event === 'completion') {
|
|
281
|
-
// remove listener
|
|
282
|
-
this.nativeEvents.removeListener('scanResult', this.onScanResultFunction);
|
|
283
|
-
|
|
284
|
-
if (!!error === false) {
|
|
285
|
-
|
|
286
|
-
// create button object
|
|
287
|
-
ButtonObject = new Flic2Button(button);
|
|
288
|
-
|
|
289
|
-
// save to known buttons
|
|
290
|
-
this.knownButtons[ButtonObject.getUuid()] = ButtonObject;
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// check if error
|
|
296
|
-
this.emit('scanResult', {
|
|
297
|
-
event: event,
|
|
298
|
-
error: !!error,
|
|
299
|
-
result: result,
|
|
300
|
-
button: ButtonObject,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Event: did receive button event.
|
|
307
|
-
* Emits the event we received from the button.
|
|
308
|
-
*
|
|
309
|
-
* @version 1.0.0
|
|
310
|
-
*/
|
|
311
|
-
didReceiveButtonEvent(eventData){
|
|
312
|
-
|
|
313
|
-
// button uuid
|
|
314
|
-
const buttonUuid = eventData.button.uuid;
|
|
315
|
-
|
|
316
|
-
// check if we have the button object in memory
|
|
317
|
-
if (typeof this.knownButtons[buttonUuid] !== 'undefined'){
|
|
318
|
-
|
|
319
|
-
// update
|
|
320
|
-
const knownButton = this.knownButtons[buttonUuid];
|
|
321
|
-
knownButton.setData(eventData.button);
|
|
322
|
-
|
|
323
|
-
// proxy to button for individual listen events
|
|
324
|
-
knownButton.didReceiveButtonEvent(eventData);
|
|
325
|
-
|
|
326
|
-
} else {
|
|
327
|
-
|
|
328
|
-
// create it
|
|
329
|
-
this.knownButtons[buttonUuid] = new Flic2Button(eventData.button);
|
|
330
|
-
|
|
331
|
-
// we do not call didReceiveButtonEvent because there could
|
|
332
|
-
// not be any listeners at this point
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// emit to application
|
|
337
|
-
this.emit(eventData.event, {
|
|
338
|
-
event: eventData.event,
|
|
339
|
-
queued: eventData.queued,
|
|
340
|
-
age: eventData.age,
|
|
341
|
-
error: eventData.error,
|
|
342
|
-
button: this.knownButtons[buttonUuid],
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
connectAllKnownButtons() {
|
|
350
|
-
|
|
351
|
-
// pass to native module
|
|
352
|
-
Flic2Module.connectAllKnownButtons();
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
buttonConnect(uuid){
|
|
357
|
-
return new Promise(resolve => {
|
|
358
|
-
|
|
359
|
-
// pass to native module
|
|
360
|
-
Flic2Module.connectButton(uuid, resolve);
|
|
361
|
-
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
buttonForget(uuid) {
|
|
366
|
-
return new Promise(resolve => {
|
|
367
|
-
|
|
368
|
-
// remove from known list
|
|
369
|
-
delete this.knownButtons[uuid];
|
|
370
|
-
|
|
371
|
-
// pass to native module
|
|
372
|
-
Flic2Module.forgetButton(uuid, resolve);
|
|
373
|
-
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
buttonDisconnect(uuid) {
|
|
378
|
-
return new Promise(resolve => {
|
|
379
|
-
|
|
380
|
-
// pass to native module
|
|
381
|
-
Flic2Module.disconnectButton(uuid, resolve);
|
|
382
|
-
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
disconnectAllKnownButtons() {
|
|
387
|
-
|
|
388
|
-
// pass to native module
|
|
389
|
-
Flic2Module.disconnectAllKnownButtons();
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
forgetAllButtons() {
|
|
394
|
-
|
|
395
|
-
// pass to native module
|
|
396
|
-
Flic2Module.forgetAllButtons();
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
buttonSetName(uuid, name) {
|
|
400
|
-
return new Promise(resolve => {
|
|
401
|
-
|
|
402
|
-
// pass to native module
|
|
403
|
-
Flic2Module.setName(uuid, name, resolve);
|
|
404
|
-
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
buttonSetMode(uuid, mode) {
|
|
409
|
-
return new Promise(resolve => {
|
|
410
|
-
|
|
411
|
-
// ios only
|
|
412
|
-
if (Platform.OS === 'ios') {
|
|
413
|
-
|
|
414
|
-
// pass to native module
|
|
415
|
-
Flic2Module.setMode(uuid, mode, resolve);
|
|
416
|
-
|
|
417
|
-
} else {
|
|
418
|
-
|
|
419
|
-
resolve();
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// export as singleton
|
|
430
|
-
export default new Flic2();
|