-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19f79a8
commit 85970cb
Showing
17 changed files
with
1,023 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# expo-mds | ||
|
||
Expo Module for Movesense | ||
|
||
Please note that you need hermes as js engine for this lib to work on Android | ||
|
||
# API documentation | ||
|
||
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/mds.md) | ||
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/mds/) | ||
|
||
# Installation in managed Expo projects | ||
|
||
For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release. | ||
|
||
# Installation in bare React Native projects | ||
|
||
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing. | ||
|
||
### Add the package to your npm dependencies | ||
|
||
``` | ||
npm install expo-mds | ||
``` | ||
|
||
### Configure for iOS | ||
|
||
Run `npx pod-install` after installing the npm package. | ||
|
||
|
||
### Configure for Android | ||
|
||
|
||
|
||
# Contributing | ||
|
||
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
<manifest> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="expo.modules.mds"> | ||
<uses-permission android:name="android.permission.BLUETOOTH" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package expo.modules.mds; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public interface BleScanListener { | ||
void onDeviceFound(@NonNull String name, @NonNull String address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package expo.modules.mds; | ||
|
||
import android.bluetooth.BluetoothAdapter; | ||
import android.bluetooth.BluetoothDevice; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
|
||
public class BleScanner { | ||
|
||
private final BroadcastReceiver receiver; | ||
|
||
private final BluetoothAdapter mBluetoothAdapter; | ||
|
||
private final Context context; | ||
|
||
BleScanner(Context context, final BleScanListener listener) { | ||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | ||
this.context = context; | ||
receiver = new BroadcastReceiver() { | ||
public void onReceive(Context context, Intent intent) { | ||
String action = intent.getAction(); | ||
if (BluetoothDevice.ACTION_FOUND.equals(action)) { | ||
BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); | ||
var name = device.getName(); | ||
var alias = device.getAlias(); | ||
var address = device.getAddress(); | ||
if(address != null && name != null){ | ||
listener.onDeviceFound(name != null ? name : address, address); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
public void scan() { | ||
IntentFilter filter = new IntentFilter(); | ||
filter.addAction(BluetoothDevice.ACTION_FOUND); | ||
context.registerReceiver(receiver, filter); | ||
mBluetoothAdapter.startDiscovery(); | ||
} | ||
|
||
public void stopScan() { | ||
mBluetoothAdapter.cancelDiscovery(); | ||
try { | ||
context.unregisterReceiver(receiver); | ||
} catch (Throwable t) { | ||
|
||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.