@playerdata/react-native-mcu-manager
React Native Wrappers for MCUMgr's Android / iOS client libraries
Getting started
Installation in managed Expo projects
For managed Expo projects,
we hope this will Just Work :tm:.
The example app uses Expo Prebuild, so we've some confidence, but let us know
how you get on.
Installation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.
Add the package to your npm dependencies
npm install @playerdata/react-native-mcu-manager
Configure for iOS
Run npx pod-install after installing the npm package.
Configure for Android
Usage
import McuManager, { ProgressEvent, UploadEvents } from '@playerdata/react-native-mcu-manager';
const onUploadProgress = (progress: ProgressEvent) => {
console.log("Upload progress: ", progress.bleId, progress.progress);
};
const onUploadStateChanged = (progress: ProgressEvent) => {
console.log("Upload state change: ", progress.bleId, progress.state);
};
UploadEvents.addListener('uploadProgress', onUploadProgress);
UploadEvents.addListener('uploadStateChanged', onUploadStateChanged);
McuManager.updateDevice(bluetoothId, fileUri)
Contributing
Contributions are very welcome!
There are many examples of expo modules in the expo repo packages like
https://github.com/expo/expo/blob/main/packages/expo-camera/README.md
Development Workflow
Install dependencies:
npm install
You should use the example app to test your changes:
cd example
npx expo prebuild
From the top level of the repo, you can use npm run open:(ios|android) to open
the appropriate IDE.
For Swift files, you'll find the source files at Pods > Development Pods > ReactNativeMcuManager
in XCode.
For Kotlin, you'll find the source files at reactnativemcumanager under Android in Android Studio.
Make sure your code passes TypeScript and ESLint. Run the following to verify:
npm run typecheck
npm run lint
To fix formatting errors, run the following:
npm run lint --fix
Remember to add unit tests for your change if possible. Run the unit tests by:
npm run test