Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update docs #1121

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions INTRO.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ It is worth to note that scanning function may emit one device multiple times. H
when device is connected it won't broadcast and needs to be disconnected from central
to be scanned again. Only one scanning listener can be registered.

### Bluetooth 5 Advertisements in Android

To see devices that use Bluetooth 5 Advertising Extension you have to set the `legacyScan` variable to `false` in {@link #scanoptions|Scan options} when you are starting {@link #blemanagerstartdevicescan|BleManager.startDeviceScan()},

## Connecting and discovering services and characteristics

Once device is scanned it is in disconnected state. We need to connect to it and discover
Expand Down
73 changes: 73 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,12 @@ <h3 class='mb0 no-anchor'>react-native-ble-plx</h3>
#callbackType
</a></li>

<li><a
href='#scanoptionslegacyscan'
class='regular pre-open'>
#legacyScan
</a></li>

</ul>


Expand Down Expand Up @@ -2006,6 +2012,16 @@ <h2>Ask for permissions</h2>

<span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>
}</pre>
<p>With <code>neverForLocation</code> flag active, you can remove <code>ACCESS_FINE_LOCATION</code> permissions ask e.g.:</p>
<pre class='hljs'><span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT
])

<span class="hljs-keyword">return</span> (
result[<span class="hljs-string">'android.permission.BLUETOOTH_CONNECT'</span>] === PermissionsAndroid.RESULTS.GRANTED &amp;&amp;
result[<span class="hljs-string">'android.permission.BLUETOOTH_SCAN'</span>] === PermissionsAndroid.RESULTS.GRANTED
)</pre>
<h2>Waiting for Powered On state</h2>
<p>When iOS application launches BLE stack is not immediately available and we need to check its status.
To detect current state and following state changes we can use <code>onStateChange()</code> function:</p>
Expand Down Expand Up @@ -2041,6 +2057,8 @@ <h2>Scanning devices</h2>
<p>It is worth to note that scanning function may emit one device multiple times. However
when device is connected it won't broadcast and needs to be disconnected from central
to be scanned again. Only one scanning listener can be registered.</p>
<h3>Bluetooth 5 Advertisements</h3>
<p>To see devices that use Bluetooth 5 Advertising Extension you have to set the legacyScan variable to <code>false</code> in <a href="#scanoptions">Scan options</a> when you are starting <a href="#blemanagerstartdevicescan">BleManager.startDeviceScan()</a>,</p>
<h2>Connecting and discovering services and characteristics</h2>
<p>Once device is scanned it is in disconnected state. We need to connect to it and discover
all services and characteristics it contains. Services may be understood
Expand Down Expand Up @@ -16323,6 +16341,61 @@ <h3 class='fl m0' id='scanoptions'>












</section>

</div>
</div>

<div class='border-bottom' id='scanoptionslegacyscan'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
<span class='code strong strong truncate'>legacyScan</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>Use legacyScan (default true) [Android only]
<a href="https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean">https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean</a>)</p>

<div class='pre p1 fill-light mt0'>legacyScan</div>

<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>
</p>























Expand Down
7 changes: 7 additions & 0 deletions src/TypeDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ export interface ScanOptions {
* @instance
*/
callbackType?: $Values<typeof ScanCallbackType>;
/**
* Use legacyScan (default true) [Android only]
* https://developer.android.com/reference/android/bluetooth/le/ScanSettings.Builder#setLegacy(boolean)
* @memberof ScanOptions
* @instance
*/
legacyScan?: boolean;
}

/**
Expand Down