Skip to content

Commit 99c9990

Browse files
Exploring integrating capacitor ble code
This version is a bit messy but will DFU flash the data collection hex. Needs more dialog steps, progress, feeedback on success/fail. Having said that, I'm going to go straight for reconnecting for the accelerometer data.
1 parent d47f637 commit 99c9990

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2554
-111
lines changed

android/app/capacitor.build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ android {
99

1010
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
1111
dependencies {
12+
implementation project(':capacitor-community-bluetooth-le')
1213
implementation project(':capacitor-community-safe-area')
14+
implementation project(':capacitor-filesystem')
15+
implementation project(':microbit-capacitor-community-nordic-dfu')
1316

1417
}
1518

android/app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
</application>
3131

3232
<!-- Permissions -->
33+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
34+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
35+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
36+
37+
<!-- BLUETOOTH_CONNECT permission is required from Android 12 to connect to a Bluetooth LE device -->
38+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
39+
40+
<!-- ACCESS_BACKGROUND_LOCATION permission is required required to trigger a successful DFU whilst the device screen is turned off: https://github.com/NordicSemiconductor/Android-DFU-Library -->
41+
<!-- Removed to avoid problems with new Google Play approval process -->
42+
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> -->
43+
44+
<!-- FOREGROUND_SERVICE permission is required required: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/321 -->
45+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
3346

3447
<uses-permission android:name="android.permission.INTERNET" />
3548
</manifest>

android/capacitor.settings.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,14 @@
22
include ':capacitor-android'
33
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
44

5+
include ':capacitor-community-bluetooth-le'
6+
project(':capacitor-community-bluetooth-le').projectDir = new File('../node_modules/@capacitor-community/bluetooth-le/android')
7+
58
include ':capacitor-community-safe-area'
69
project(':capacitor-community-safe-area').projectDir = new File('../node_modules/@capacitor-community/safe-area/android')
10+
11+
include ':capacitor-filesystem'
12+
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
13+
14+
include ':microbit-capacitor-community-nordic-dfu'
15+
project(':microbit-capacitor-community-nordic-dfu').projectDir = new File('../node_modules/@microbit/capacitor-community-nordic-dfu/android')

ios/App/App/Info.plist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
66
<string>en</string>
7+
<key>NSBluetoothAlwaysUsageDescription</key>
8+
<string>Uses Bluetooth to connect and interact with peripheral BLE devices.</string>
9+
<key>UIBackgroundModes</key>
10+
<array>
11+
<string>bluetooth-central</string>
12+
</array>
713
<key>CFBundleDisplayName</key>
814
<string>CreateAI</string>
915
<key>CFBundleExecutable</key>

ios/App/Podfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ install! 'cocoapods', :disable_input_output_paths => true
1111
def capacitor_pods
1212
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
1313
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
14+
pod 'CapacitorCommunityBluetoothLe', :path => '../../node_modules/@capacitor-community/bluetooth-le'
1415
pod 'CapacitorCommunitySafeArea', :path => '../../node_modules/@capacitor-community/safe-area'
16+
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
17+
pod 'MicrobitCapacitorCommunityNordicDfu', :path => '../../node_modules/@microbit/capacitor-community-nordic-dfu'
1518
end
1619

1720
target 'App' do

ios/App/Podfile.lock

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
11
PODS:
22
- Capacitor (7.4.4):
33
- CapacitorCordova
4+
- CapacitorCommunityBluetoothLe (7.3.0):
5+
- Capacitor
46
- CapacitorCommunitySafeArea (7.0.0-beta.5):
57
- Capacitor
68
- CapacitorCordova (7.4.4)
9+
- CapacitorFilesystem (7.1.5):
10+
- Capacitor
11+
- IONFilesystemLib (~> 1.0.1)
12+
- IONFilesystemLib (1.0.1)
13+
- MicrobitCapacitorCommunityNordicDfu (7.0.0-microbit.3):
14+
- Capacitor
15+
- NordicDFU (~> 4.16.0)
16+
- NordicDFU (4.16.0):
17+
- ZIPFoundation (= 0.9.19)
18+
- ZIPFoundation (0.9.19)
719

820
DEPENDENCIES:
921
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
22+
- "CapacitorCommunityBluetoothLe (from `../../node_modules/@capacitor-community/bluetooth-le`)"
1023
- "CapacitorCommunitySafeArea (from `../../node_modules/@capacitor-community/safe-area`)"
1124
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
25+
- "CapacitorFilesystem (from `../../node_modules/@capacitor/filesystem`)"
26+
- "MicrobitCapacitorCommunityNordicDfu (from `../../node_modules/@microbit/capacitor-community-nordic-dfu`)"
27+
28+
SPEC REPOS:
29+
trunk:
30+
- IONFilesystemLib
31+
- NordicDFU
32+
- ZIPFoundation
1233

1334
EXTERNAL SOURCES:
1435
Capacitor:
1536
:path: "../../node_modules/@capacitor/ios"
37+
CapacitorCommunityBluetoothLe:
38+
:path: "../../node_modules/@capacitor-community/bluetooth-le"
1639
CapacitorCommunitySafeArea:
1740
:path: "../../node_modules/@capacitor-community/safe-area"
1841
CapacitorCordova:
1942
:path: "../../node_modules/@capacitor/ios"
43+
CapacitorFilesystem:
44+
:path: "../../node_modules/@capacitor/filesystem"
45+
MicrobitCapacitorCommunityNordicDfu:
46+
:path: "../../node_modules/@microbit/capacitor-community-nordic-dfu"
2047

2148
SPEC CHECKSUMS:
2249
Capacitor: 09d9ff8e9618e8c4b3cab2bbee34a17215dd2fef
50+
CapacitorCommunityBluetoothLe: dd86d538624119307c46f5c67f0aa1930198e995
2351
CapacitorCommunitySafeArea: 9d1d82a77c056101a7e0b808de3eb39ef1431df4
2452
CapacitorCordova: bf648a636f3c153f652d312ae145fb508b6ffced
53+
CapacitorFilesystem: 2caf7ad6e26d68defef0631b0f09adb09a353f27
54+
IONFilesystemLib: 89258b8e3e85465da93127d25d7ce37f977e8a6f
55+
MicrobitCapacitorCommunityNordicDfu: b7d5532fff6f36c4a202ccda3be8d835c2523eb9
56+
NordicDFU: 116a4ec458945889f8e0e71759e03b23c39c3482
57+
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
2558

26-
PODFILE CHECKSUM: b14023669789a78b7a53c7515766b1a886b64d37
59+
PODFILE CHECKSUM: c99931faff9d0b8213b7a556796098549de867e5
2760

2861
COCOAPODS: 1.15.2

lang/ui.ca.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@
259259
"defaultMessage": "Cable micro USB",
260260
"description": "Label for cable icon in list of requirements"
261261
},
262+
"connect-native-start-heading": {
263+
"defaultMessage": "What you need to connect",
264+
"description": "Connection dialog heading"
265+
},
266+
"connect-native-start-requirements1": {
267+
"defaultMessage": "micro:bit with battery pack",
268+
"description": "Label for image of a micro:bit and battery pack"
269+
},
262270
"connect-or-import": {
263271
"defaultMessage": "<link1>Connecta una micro:bit de recollida de dades</link1> o <link2>importa mostres de dades</link2>",
264272
"description": "Empty data samples page text"
@@ -355,6 +363,10 @@
355363
"defaultMessage": "Connecta't mitjançant Web Bluetooth",
356364
"description": "Link to alternative connection method"
357365
},
366+
"connect-tablet": {
367+
"defaultMessage": "iPad or Android tablet",
368+
"description": "Label for image of a tablet with a superimposed bluetooth icon"
369+
},
358370
"connect-to-record": {
359371
"defaultMessage": "Connecta't per registrar mostres de dades",
360372
"description": "Live graph disconnected micro:bit status message for data samples page"
@@ -383,6 +395,10 @@
383395
"defaultMessage": "amb piles",
384396
"description": "Under header 'Battery holder' this notes that batteries are required"
385397
},
398+
"connect-with-bluetooth": {
399+
"defaultMessage": "with Bluetooth enabled",
400+
"description": "Subtitle for tablet image with Bluetooth icon"
401+
},
386402
"connect-with-web-bluetooth": {
387403
"defaultMessage": "Connecta amb Web Bluetooth",
388404
"description": "Connection dialog title"

lang/ui.en.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@
259259
"defaultMessage": "Micro USB cable",
260260
"description": "Label for cable icon in list of requirements"
261261
},
262+
"connect-native-start-heading": {
263+
"defaultMessage": "What you need to connect",
264+
"description": "Connection dialog heading"
265+
},
266+
"connect-native-start-requirements1": {
267+
"defaultMessage": "micro:bit with battery pack",
268+
"description": "Label for image of a micro:bit and battery pack"
269+
},
262270
"connect-or-import": {
263271
"defaultMessage": "<link1>Connect a data collection micro:bit</link1> or <link2>import data samples</link2>",
264272
"description": "Empty data samples page text"
@@ -355,6 +363,10 @@
355363
"defaultMessage": "Connect using Web Bluetooth instead",
356364
"description": "Link to alternative connection method"
357365
},
366+
"connect-tablet": {
367+
"defaultMessage": "iPad or Android tablet",
368+
"description": "Label for image of a tablet with a superimposed bluetooth icon"
369+
},
358370
"connect-to-record": {
359371
"defaultMessage": "Connect to record data samples",
360372
"description": "Live graph disconnected micro:bit status message for data samples page"
@@ -383,6 +395,10 @@
383395
"defaultMessage": "with batteries",
384396
"description": "Under header 'Battery holder' this notes that batteries are required"
385397
},
398+
"connect-with-bluetooth": {
399+
"defaultMessage": "with Bluetooth enabled",
400+
"description": "Subtitle for tablet image with Bluetooth icon"
401+
},
386402
"connect-with-web-bluetooth": {
387403
"defaultMessage": "Connect with Web Bluetooth",
388404
"description": "Connection dialog title"

lang/ui.es-es.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@
259259
"defaultMessage": "Cable micro USB",
260260
"description": "Label for cable icon in list of requirements"
261261
},
262+
"connect-native-start-heading": {
263+
"defaultMessage": "What you need to connect",
264+
"description": "Connection dialog heading"
265+
},
266+
"connect-native-start-requirements1": {
267+
"defaultMessage": "micro:bit with battery pack",
268+
"description": "Label for image of a micro:bit and battery pack"
269+
},
262270
"connect-or-import": {
263271
"defaultMessage": "<link1>Conecta una colección de datos de micro:bit</link1> o <link2>importa muestras de datos</link2>",
264272
"description": "Empty data samples page text"
@@ -355,6 +363,10 @@
355363
"defaultMessage": "Conéctate utilizando Web Bluetooth en su lugar",
356364
"description": "Link to alternative connection method"
357365
},
366+
"connect-tablet": {
367+
"defaultMessage": "iPad or Android tablet",
368+
"description": "Label for image of a tablet with a superimposed bluetooth icon"
369+
},
358370
"connect-to-record": {
359371
"defaultMessage": "Conecta para grabar muestras de datos",
360372
"description": "Live graph disconnected micro:bit status message for data samples page"
@@ -383,6 +395,10 @@
383395
"defaultMessage": "con pilas",
384396
"description": "Under header 'Battery holder' this notes that batteries are required"
385397
},
398+
"connect-with-bluetooth": {
399+
"defaultMessage": "with Bluetooth enabled",
400+
"description": "Subtitle for tablet image with Bluetooth icon"
401+
},
386402
"connect-with-web-bluetooth": {
387403
"defaultMessage": "Conectar con Web Bluetooth",
388404
"description": "Connection dialog title"

lang/ui.fr.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@
259259
"defaultMessage": "Câble Micro USB",
260260
"description": "Label for cable icon in list of requirements"
261261
},
262+
"connect-native-start-heading": {
263+
"defaultMessage": "What you need to connect",
264+
"description": "Connection dialog heading"
265+
},
266+
"connect-native-start-requirements1": {
267+
"defaultMessage": "micro:bit with battery pack",
268+
"description": "Label for image of a micro:bit and battery pack"
269+
},
262270
"connect-or-import": {
263271
"defaultMessage": "<link1>Connecter un micro:bit de collecte de données</link1> ou <link2>importer des échantillons de données</link2>",
264272
"description": "Empty data samples page text"
@@ -355,6 +363,10 @@
355363
"defaultMessage": "Se connecter en utilisant Web Bluetooth à la place",
356364
"description": "Link to alternative connection method"
357365
},
366+
"connect-tablet": {
367+
"defaultMessage": "iPad or Android tablet",
368+
"description": "Label for image of a tablet with a superimposed bluetooth icon"
369+
},
358370
"connect-to-record": {
359371
"defaultMessage": "Se connecter aux échantillons de données d'enregistrement",
360372
"description": "Live graph disconnected micro:bit status message for data samples page"
@@ -383,6 +395,10 @@
383395
"defaultMessage": "avec des piles",
384396
"description": "Under header 'Battery holder' this notes that batteries are required"
385397
},
398+
"connect-with-bluetooth": {
399+
"defaultMessage": "with Bluetooth enabled",
400+
"description": "Subtitle for tablet image with Bluetooth icon"
401+
},
386402
"connect-with-web-bluetooth": {
387403
"defaultMessage": "Se connecter avec Web Bluetooth",
388404
"description": "Connection dialog title"

0 commit comments

Comments
 (0)