
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@naturalclar/react-native-ble-peripheral
Advanced tools
a simulator for a BLE peripheral, to help with testing BLE apps without an actual peripheral BLE device
This is a forked repository for testing purpose. The original repository is located at https://github.com/himelbrand/react-native-ble-peripheral.git
Native BLE Peripheral in React Native
This is a simulator for a BLE peripheral, to help with testing BLE apps without an actual peripheral BLE device this project is not yet complete, for all ready parts see documentation below. (docs are not complete, feel free to improve them)
if you would like to contribute to this project or suggest more future features you're welcome to so via an issue or pull request.
right now this package does not support IOS, so any one that wants to help and contribute the IOS support is more than welcome
npm install react-native-ble-peripheral --save
or
yarn add react-native-ble-peripheral
npm page - https://www.npmjs.com/package/react-native-ble-peripheral
AndroidManifest.xml add:
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
react-native link
android/settings.gradle...
include ':react-native-ble-peripheral'
project(':react-native-ble-peripheral').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ble-peripheral/android')
android/app/build.gradle...
dependencies {
/* YOUR DEPENDENCIES HERE */
compile project(':react-native-ble-peripheral') // <--- add this
}
import com.himelbrand.forwardcalls.RNForwardCallsPackage; // <--- import
public class MainActivity extends ReactActivity {
......
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNBLEPackage() // <--- Add this
);
}
......
}
import BLEPeripheral from "react-native-ble-peripheral";
BLEPeripheral.addService(UUID:string, primary:boolean)
BLEPeripheral.addService("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", true); //for primary service
BLEPeripheral.addService("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", false); //for non primary service
BLEPeripheral.addCharacteristicToService(ServiceUUID:string, UUID:string, permissions:number, properties:number)
https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic.html the link above is for permissions and properties constants info
Permissions:
Properties:
BLEPeripheral.addCharacteristicToService(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
16 | 1,
8
); //this is a Characteristic with read and write permissions and notify property
BLEPeripheral.sendNotificationToDevices(ServiceUUID:string, CharacteristicUUID:string, data:byte[])
BLEPeripheral.sendNotificationToDevices(
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
[0x10, 0x01, 0xa1, 0x80]
); //sends a notification to all connected devices that, using the char uuid given
note:use this only after adding services and characteristics
BLEPeripheral.start()
.then(res => {
console.log(res);
})
.catch(error => {
console.log(error);
});
In case of error, these are the error codes:
BLEPeripheral.stop();
BLEPeripheral.setName(name:string)
This method sets the name of the device broadcast, before calling start.
BLEPeripheral.setName("RNBLETEST");
DOCs and project is under development Any help would be welcome... feel free to contact me
FAQs
a simulator for a BLE peripheral, to help with testing BLE apps without an actual peripheral BLE device
We found that @naturalclar/react-native-ble-peripheral demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.