-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
05e9bab
commit 703fe9c
Showing
12 changed files
with
1,035 additions
and
899 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
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,20 @@ | ||
<div class="mb-5 pl-5 switch-container"> | ||
<label class="switch"> | ||
<input type="checkbox" id="theme-switch" /> | ||
<span class="slider round"> | ||
<span class="icon sun">☀️</span> | ||
<span class="icon moon">🌙</span> | ||
</span> | ||
</label> | ||
</div> | ||
<script> | ||
document | ||
.getElementById("theme-switch") | ||
.addEventListener("change", function (event) { | ||
if (event.target.checked) { | ||
jtd.setTheme("light"); | ||
} else { | ||
jtd.setTheme("dark"); | ||
} | ||
}); | ||
</script> |
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,9 +1,120 @@ | ||
|
||
.site-title { | ||
@include mq(md) { | ||
font-size: 0.9rem !important; | ||
} | ||
|
||
@include mq(lg) { | ||
font-size: 1rem !important; | ||
} | ||
} | ||
|
||
.switch-container { | ||
display: none; | ||
|
||
@include mq(md) { | ||
display: block; | ||
width: $nav-width-md; | ||
} | ||
|
||
@include mq(lg) { | ||
display: block; | ||
width: $nav-width; | ||
} | ||
} | ||
|
||
.switch { | ||
position: relative; | ||
display: inline-block; | ||
width: 50px; | ||
height: 25px; | ||
} | ||
|
||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
|
||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: #ccc; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
} | ||
|
||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 26px; | ||
width: 26px; | ||
left: 4px; | ||
bottom: 4px; | ||
background-color: white; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
} | ||
|
||
input:checked+.slider { | ||
background-color: #2196F3; | ||
} | ||
|
||
input:focus+.slider { | ||
box-shadow: 0 0 1px #2196F3; | ||
} | ||
|
||
input:checked+.slider:before { | ||
-webkit-transform: translateX(26px); | ||
-ms-transform: translateX(26px); | ||
transform: translateX(26px); | ||
} | ||
|
||
/* Forma rotonda dello slider */ | ||
.slider.round { | ||
border-radius: 34px; | ||
} | ||
|
||
.slider.round:before { | ||
border-radius: 50%; | ||
} | ||
|
||
.slider:before { | ||
height: 21px; | ||
width: 21px; | ||
left: 2px; | ||
bottom: 2px; | ||
} | ||
|
||
.slider { | ||
.icon { | ||
display: none; | ||
position: absolute; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
color: #FFF; | ||
} | ||
|
||
/* Icona del sole */ | ||
.sun { | ||
left: 4px; | ||
} | ||
|
||
/* Icona della luna */ | ||
.moon { | ||
right: 4px; | ||
} | ||
} | ||
|
||
|
||
/* Mostra l'icona appropriata in base allo stato dello switch */ | ||
input:checked+.slider .sun { | ||
display: block; | ||
} | ||
|
||
input:not(:checked)+.slider .moon { | ||
display: block; | ||
} |
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,15 @@ | ||
--- | ||
layout: page | ||
title: Changelog | ||
permalink: /changelog/ | ||
nav_order: 100 | ||
--- | ||
|
||
# Changelog | ||
|
||
To read all the details go to the [Github Releases section](https://github.com/innoveit/react-native-ble-manager/releases). | ||
|
||
## Release v11.0.X | ||
|
||
- The iOS module has been completely rewritten in Swift. | ||
- The manufacturerData field has been made consistent between Android and iOS. |
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,163 @@ | ||
--- | ||
layout: page | ||
title: Events | ||
permalink: /events/ | ||
nav_order: 2 | ||
parent: Usage | ||
--- | ||
|
||
# Events | ||
|
||
### BleManagerStopScan | ||
|
||
The scanning for peripherals is ended. | ||
|
||
**Arguments** | ||
|
||
- `status` - `Number` - [iOS] the reason for stopping the scan. Error code 10 is used for timeouts, 0 covers everything else. [Android] the reason for stopping the scan (<https://developer.android.com/reference/android/bluetooth/le/ScanCallback#constants_1>). Error code 10 is used for timeouts | ||
|
||
**Examples** | ||
|
||
```js | ||
bleManagerEmitter.addListener("BleManagerStopScan", (args) => { | ||
// Scanning is stopped | ||
}); | ||
``` | ||
|
||
### BleManagerDidUpdateState | ||
|
||
The BLE change state. | ||
|
||
**Arguments** | ||
|
||
- `state` - `String` - the new BLE state. can be one of `unknown` (iOS only), `resetting` (iOS only), `unsupported`, `unauthorized` (iOS only), `on`, `off`, `turning_on` (android only), `turning_off` (android only). | ||
|
||
**Examples** | ||
|
||
```js | ||
bleManagerEmitter.addListener("BleManagerDidUpdateState", (args) => { | ||
// The new state: args.state | ||
}); | ||
``` | ||
|
||
### BleManagerDiscoverPeripheral | ||
|
||
The scanning find a new peripheral. | ||
|
||
**Arguments** | ||
|
||
- `id` - `String` - the id of the peripheral | ||
- `name` - `String` - the name of the peripheral | ||
- `rssi` - `Number` - the RSSI value | ||
- `advertising` - `JSON` - the advertising payload, here are some examples: | ||
- `isConnectable` - `Boolean` | ||
- `serviceUUIDs` - `Array of String` | ||
- `manufacturerData` - `JSON` - contains a json with the company id as field and the custom value as raw `bytes` and `data` (Base64 encoded string) | ||
- `serviceData` - `JSON` - contains the raw `bytes` and `data` (Base64 encoded string) | ||
- `txPowerLevel` - `Int` | ||
- `rawData` - [Android only] `JSON` - contains the raw `bytes` and `data` (Base64 encoded string) of the all advertising data | ||
|
||
**Examples** | ||
|
||
```js | ||
bleManagerEmitter.addListener("BleManagerDiscoverPeripheral", (args) => { | ||
// The id: args.id | ||
// The name: args.name | ||
}); | ||
``` | ||
|
||
### BleManagerDidUpdateValueForCharacteristic | ||
|
||
A characteristic notify a new value. | ||
|
||
**Arguments** | ||
|
||
- `value` — `Array` — the read value | ||
- `peripheral` — `String` — the id of the peripheral | ||
- `characteristic` — `String` — the UUID of the characteristic | ||
- `service` — `String` — the UUID of the characteristic | ||
|
||
> Event will only be emitted after successful `startNotification`. | ||
**Example** | ||
|
||
```js | ||
import { bytesToString } from "convert-string"; | ||
import { NativeModules, NativeEventEmitter } from "react-native"; | ||
|
||
const BleManagerModule = NativeModules.BleManager; | ||
const bleManagerEmitter = new NativeEventEmitter(BleManagerModule); | ||
|
||
async function connectAndPrepare(peripheral, service, characteristic) { | ||
// Connect to device | ||
await BleManager.connect(peripheral); | ||
// Before startNotification you need to call retrieveServices | ||
await BleManager.retrieveServices(peripheral); | ||
// To enable BleManagerDidUpdateValueForCharacteristic listener | ||
await BleManager.startNotification(peripheral, service, characteristic); | ||
// Add event listener | ||
bleManagerEmitter.addListener( | ||
"BleManagerDidUpdateValueForCharacteristic", | ||
({ value, peripheral, characteristic, service }) => { | ||
// Convert bytes array to string | ||
const data = bytesToString(value); | ||
console.log(`Received ${data} for characteristic ${characteristic}`); | ||
} | ||
); | ||
// Actions triggereng BleManagerDidUpdateValueForCharacteristic event | ||
} | ||
``` | ||
|
||
### BleManagerConnectPeripheral | ||
|
||
A peripheral was connected. | ||
|
||
**Arguments** | ||
|
||
- `peripheral` - `String` - the id of the peripheral | ||
- `status` - `Number` - [Android only] connect [`reasons`](<https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt,%20int,%20int)>) | ||
|
||
### BleManagerDisconnectPeripheral | ||
|
||
A peripheral was disconnected. | ||
|
||
**Arguments** | ||
|
||
- `peripheral` - `String` - the id of the peripheral | ||
- `status` - `Number` - [Android only] disconnect [`reasons`](<https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt,%20int,%20int)>) | ||
- `domain` - `String` - [iOS only] disconnect error domain | ||
- `code` - `Number` - [iOS only] disconnect error code (<https://developer.apple.com/documentation/corebluetooth/cberror/code>) | ||
|
||
### BleManagerPeripheralDidBond | ||
|
||
A bond with a peripheral was established | ||
|
||
**Arguments** | ||
|
||
Object with information about the device | ||
|
||
### BleManagerCentralManagerWillRestoreState [iOS only] | ||
|
||
This is fired when [`centralManager:WillRestoreState:`](https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518819-centralmanager) is called (app relaunched in the background to handle a bluetooth event). | ||
|
||
**Arguments** | ||
|
||
- `peripherals` - `Array` - an array of previously connected peripherals. | ||
|
||
_For more on performing long-term bluetooth actions in the background:_ | ||
|
||
[iOS Bluetooth State Preservation and Restoration](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW10) | ||
|
||
[iOS Relaunch Conditions](https://developer.apple.com/library/archive/qa/qa1962/_index.html) | ||
|
||
### BleManagerDidUpdateNotificationStateFor [iOS only] | ||
|
||
The peripheral received a request to start or stop providing notifications for a specified characteristic's value. | ||
|
||
**Arguments** | ||
|
||
- `peripheral` - `String` - the id of the peripheral | ||
- `characteristic` - `String` - the UUID of the characteristic | ||
- `isNotifying` - `Boolean` - Is the characteristic notifying or not | ||
- `domain` - `String` - [iOS only] error domain | ||
- `code` - `Number` - [iOS only] error code |
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
Oops, something went wrong.