| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 个月前 | ||
| 1 年前 | ||
| 4 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 1 年前 |
Omi SDK Example App
This is a comprehensive example application demonstrating how to use the Omi SDK for React Native to connect to and interact with Omi devices.
Features
- Scan for nearby Omi devices
- Connect to and disconnect from devices
- Get audio codec information
- Monitor battery levels
- Stream audio data from the device
- Real-time audio transcription using Deepgram API
Prerequisites
- React Native development environment with Expo
- An Omi device for testing
- (Optional) Deepgram API key for transcription features
Installation
- Clone the repository
- Install dependencies:
cd sdks/react-native/example
npm install
# or
yarn install
Running the Example
This example uses Expo, which simplifies the development process.
Start the development server
npm start
# or
yarn start
Run on iOS device
npm run ios
# or
yarn ios
Run on Android device
npm run android
# or
yarn android
Usage Guide
Bluetooth Permissions
The app will automatically request Bluetooth permissions when needed. If permissions are denied, you'll see a banner with instructions to enable them.
Scanning for Devices
- Tap "Scan for Devices" to begin searching for nearby Omi devices
- The scan will automatically stop after 30 seconds, or you can tap "Stop Scan" to end it manually
- Found devices will appear in the list with their name and signal strength (RSSI)
Connecting to a Device
- Tap "Connect" next to the device you want to connect to
- Once connected, additional device functions will become available
- To disconnect, tap "Disconnect"
Device Functions
Once connected, you can:
- Get Audio Codec: Retrieves the audio codec used by the device
- Get Battery Level: Shows the current battery percentage
- Start/Stop Audio Listener: Begins/ends streaming audio data from the device
Transcription (Optional)
The app includes integration with Deepgram for real-time audio transcription:
- Enable the "Enable Transcription" checkbox
- Enter your Deepgram API key
- Start the audio listener
- Tap "Start Transcription" to begin converting audio to text
- Transcription results will appear at the bottom of the screen
Troubleshooting
Common Issues
-
Device not found during scanning
- Ensure Bluetooth is enabled on your device
- Check that you have granted the necessary permissions
- Make sure the Omi device is powered on and in range
-
Connection fails
- Try restarting the Omi device
- Ensure the device is not connected to another application
- Check the battery level of the Omi device
-
Audio data not received
- Verify that the device supports the audio service
- Check that the device is properly connected
-
Transcription not working
- Verify your Deepgram API key is correct
- Ensure you have an active internet connection
- Check that audio is being received from the device
Code Structure
The example app demonstrates:
- Proper lifecycle management of BLE connections
- Handling permissions on both iOS and Android
- Efficient audio data processing
- Integration with third-party services (Deepgram)
- Responsive UI for different device states
License
MIT