diff --git a/example/app.config.ts b/example/app.config.ts
index 23f9c8ad..4661c24d 100644
--- a/example/app.config.ts
+++ b/example/app.config.ts
@@ -4,9 +4,11 @@ import 'ts-node/register';
const config: ExpoConfig = {
name: "react-native-mcu-manager-example",
slug: "react-native-mcu-manager-example",
- version: "1.0.0",
- orientation: "portrait",
assetBundlePatterns: ["**/*"],
+ orientation: "portrait",
+ platforms: ["ios", "android"],
+ scheme: "rnmcumgr",
+ version: "1.0.0",
splash: {
image: ".assets/images/pd.png",
backgroundColor: "#FFFFFF",
@@ -27,6 +29,7 @@ const config: ExpoConfig = {
},
plugins: [
["expo-document-picker"],
+ ["expo-router"],
["./gradlePlugin.ts"]
]
};
diff --git a/example/index.ts b/example/index.ts
deleted file mode 100644
index 018d06f9..00000000
--- a/example/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { registerRootComponent } from 'expo';
-
-import App from './src/App';
-
-// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
-// It also ensures that whether you load the app in Expo Go or in a native build,
-// the environment is set up appropriately
-registerRootComponent(App);
diff --git a/example/package.json b/example/package.json
index 90416df4..e27849a8 100644
--- a/example/package.json
+++ b/example/package.json
@@ -1,8 +1,9 @@
{
"name": "react-native-mcu-manager-example",
"description": "Example app for react-native-mcu-manager",
+ "main": "expo-router/entry",
"version": "0.0.1",
- "private": true,
+ "license": "MIT",
"scripts": {
"android": "expo run:android",
"ios": "expo run:ios",
@@ -13,12 +14,19 @@
"dependencies": {
"@playerdata/react-native-mcu-manager": "workspace:*",
"expo": "52.0.25",
+ "expo-constants": "~17.0.4",
"expo-document-picker": "13.0.2",
+ "expo-linking": "~7.0.4",
+ "expo-router": "~4.0.16",
"expo-splash-screen": "0.29.20",
+ "expo-status-bar": "~2.0.1",
"lodash": "4.17.21",
"react": "18.3.1",
"react-native": "0.76.3",
"react-native-ble-plx": "3.4.0",
+ "react-native-reanimated": "~3.16.1",
+ "react-native-safe-area-context": "4.12.0",
+ "react-native-screens": "~4.4.0",
"react-native-toast-message": "2.2.1"
},
"devDependencies": {
@@ -27,7 +35,6 @@
"@types/lodash": "4.17.14",
"@types/react": "19.0.7",
"metro-react-native-babel-preset": "0.77.0",
- "pod-install": "0.3.4",
"ts-node": "^10.9.2",
"typescript": "5.7.3"
}
diff --git a/example/src/app/(home)/_layout.tsx b/example/src/app/(home)/_layout.tsx
new file mode 100644
index 00000000..f61245a7
--- /dev/null
+++ b/example/src/app/(home)/_layout.tsx
@@ -0,0 +1,15 @@
+import { Stack } from 'expo-router';
+
+const HomeLayout = () => {
+ return (
+
+
+
+
+ );
+};
+
+export default HomeLayout;
diff --git a/example/src/app/(home)/index.tsx b/example/src/app/(home)/index.tsx
new file mode 100644
index 00000000..94a04ab5
--- /dev/null
+++ b/example/src/app/(home)/index.tsx
@@ -0,0 +1,62 @@
+import React, { useState } from 'react';
+import { Button, StyleSheet, Text, View } from 'react-native';
+
+import { Link } from 'expo-router';
+
+import { resetDevice } from '@playerdata/react-native-mcu-manager';
+
+import { useSelectedDevice } from '../../context/selectedDevice';
+
+const styles = StyleSheet.create({
+ root: {
+ padding: 16,
+ },
+
+ block: {
+ marginBottom: 16,
+ },
+});
+
+const Home = () => {
+ const { selectedDevice } = useSelectedDevice();
+ const [resetState, setResetState] = useState('');
+
+ return (
+
+
+
+ Select a device, then use the tabs below to choose which function to
+ test
+
+
+
+
+
+
+
+
+ Selected:
+
+ {selectedDevice?.deviceId && {selectedDevice.deviceName}}
+
+
+
+ {resetState}
+
+
+
+ );
+};
+
+export default Home;
diff --git a/example/src/app/(home)/select_device.tsx b/example/src/app/(home)/select_device.tsx
new file mode 100644
index 00000000..3f6600ba
--- /dev/null
+++ b/example/src/app/(home)/select_device.tsx
@@ -0,0 +1,42 @@
+import React from 'react';
+import { Button, FlatList, StyleSheet, Text, View } from 'react-native';
+import { useNavigation } from 'expo-router';
+
+import { useSelectedDevice } from '../../context/selectedDevice';
+import useBluetoothDevices from '../../hooks/useBluetoothDevices';
+
+const styles = StyleSheet.create({
+ list: {
+ padding: 16,
+ },
+});
+
+const SelectDevice = () => {
+ const navigation = useNavigation();
+ const { setSelectedDevice } = useSelectedDevice();
+ const { devices, error: scanError } = useBluetoothDevices();
+
+ return (
+ id}
+ renderItem={({ item }) => (
+
+ {item.name || item.id}
+
+
+ )}
+ ListHeaderComponent={() => {scanError}}
+ />
+ );
+};
+
+export default SelectDevice;
diff --git a/example/src/app/_layout.tsx b/example/src/app/_layout.tsx
new file mode 100644
index 00000000..12ad324c
--- /dev/null
+++ b/example/src/app/_layout.tsx
@@ -0,0 +1,28 @@
+import { useState } from 'react';
+import { Tabs } from 'expo-router';
+import 'react-native-reanimated';
+
+import {
+ SelectedDeviceProvider,
+ SelectedDevice,
+} from '../context/selectedDevice';
+
+const RootLayout = () => {
+ const [selectedDevice, setSelectedDevice] = useState(
+ null
+ );
+
+ return (
+
+
+
+
+
+
+ );
+};
+
+export default RootLayout;
diff --git a/example/src/App.tsx b/example/src/app/update.tsx
similarity index 66%
rename from example/src/App.tsx
rename to example/src/app/update.tsx
index e9bdab14..dc3ec7c1 100644
--- a/example/src/App.tsx
+++ b/example/src/app/update.tsx
@@ -6,8 +6,6 @@ import {
import React, { useState } from 'react';
import {
Button,
- FlatList,
- Modal,
SafeAreaView,
ScrollView,
StyleSheet,
@@ -15,9 +13,9 @@ import {
View,
} from 'react-native';
-import useBluetoothDevices from './useBluetoothDevices';
-import useFilePicker from './useFilePicker';
-import useFirmwareUpdate from './useFirmwareUpdate';
+import useFilePicker from '../hooks/useFilePicker';
+import useFirmwareUpdate from '../hooks/useFirmwareUpdate';
+import { useSelectedDevice } from '../context/selectedDevice';
const styles = StyleSheet.create({
root: {
@@ -27,18 +25,11 @@ const styles = StyleSheet.create({
block: {
marginBottom: 16,
},
-
- list: {
- padding: 16,
- },
});
-export default function App() {
- const [devicesListVisible, setDevicesListVisible] = useState(false);
- const [selectedDeviceId, setSelectedDeviceId] = useState(null);
- const [selectedDeviceName, setSelectedDeviceName] = useState(
- null
- );
+const Update = () => {
+ const { selectedDevice } = useSelectedDevice();
+
const [fileType, setFileType] = useState(
UpgradeFileType.BIN
);
@@ -46,10 +37,9 @@ export default function App() {
undefined
);
- const { devices, error: scanError } = useBluetoothDevices();
const { selectedFile, filePickerError, pickFile } = useFilePicker();
const { cancelUpdate, runUpdate, progress, state } = useFirmwareUpdate(
- selectedDeviceId,
+ selectedDevice?.deviceId || null,
selectedFile?.uri || null,
fileType,
upgradeMode
@@ -61,41 +51,14 @@ export default function App() {
Step 1 - Select Device to Update
- {selectedDeviceId && (
+ {selectedDevice?.deviceId && (
<>
Selected:
- {selectedDeviceName}
+ {selectedDevice.deviceName}
>
)}
-
-
- id}
- renderItem={({ item }) => (
-
- {item.name || item.id}
-
-
- )}
- ListHeaderComponent={() => {scanError}}
- />
-
-
Step 2 - Select Update File
@@ -154,13 +117,13 @@ export default function App() {