# react-native-esp-idf-ble-provisioning-rn

> A module to do wifi/custom data provisioning to ESP IDF

Latest version **0.2.5** (published 2022-01-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-esp-idf-ble-provisioning-rn
pnpm add react-native-esp-idf-ble-provisioning-rn
yarn add react-native-esp-idf-ble-provisioning-rn
bun add react-native-esp-idf-ble-provisioning-rn
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2022-01-11 |
| First published | 2021-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Sérgio Avilla |
| Maintainers | manbomb |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-esp-idf-ble-provisioning-rn
- Repository: https://github.com/manbomb/esp-idf-ble-provisioning-rn
- Homepage: https://github.com/manbomb/esp-idf-ble-provisioning-rn#readme
- Issues: https://github.com/manbomb/esp-idf-ble-provisioning-rn/issues
- npm.io page: https://npm.io/package/react-native-esp-idf-ble-provisioning-rn

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.5 (latest) — 2022-01-11
- 0.2.4 — 2021-06-18
- 0.2.3 — 2021-06-18
- 0.2.2 — 2021-06-18
- 0.2.1 — 2021-06-18
- 0.2.0 — 2021-06-18
- 0.1.2 — 2021-06-18
- 0.1.1 — 2021-06-17
- 0.1.0 — 2021-06-17

## README

# react-native-esp-idf-ble-provisioning-rn

A module to do wifi/custom data provisioning to ESP IDF.
<br/><br/>

## Installation

```sh
npm install react-native-esp-idf-ble-provisioning-rn
```
<br/>

## Minimum SDK Version

This module requires a minimum sdk version of 23 or higher. Look this page if you need help to do this:
### [How to specify the minSdkVersion in react native project](https://stackoverflow.com/questions/51503218/how-to-specify-the-minsdkversion-in-react-native-project)
<br/>

## Permissions

The permissions needed for use this module are: ACCESS_FINE_LOCATION, BLUETOOTH, BLUETOOTH_ADMIN. Please check them before. Useful link:
### [Permissions Android - React Native](https://reactnative.dev/docs/permissionsandroid)
<br/>

## Usage
Example of usage with comments.

```js
import EspIdfBleProvisioningRn from "react-native-esp-idf-ble-provisioning-rn";

// This method initialize the provision manager, it
// Important: this should be the first method to be called, before all others
EspIdfBleProvisioningRn.create();

// This method returns an array of objects representing the BLE devices detected by the phone
EspIdfBleProvisioningRn.scanBleDevices("PREFIX_").then(res => {
    // res is the array of devices
}).catch(e => {
    console.error(e)
})

// This method allow you to connect with the device
// Call this method before the next methods
EspIdfBleProvisioningRn.connectToBLEDevice(uuid).then(res => {
    // res will be {"success":true}
}).catch(e => {
    console.error(e)
})

// This method allow you to set pop on device
EspIdfBleProvisioningRn.setProofOfPossession("popexample");

// To get the pop of device call this method
EspIdfBleProvisioningRn.getProofOfPossession().then((pop) => {
    // pop is a string
}).catch((e) => {
    console.error(e)
})

//This method return an array of detected networks with SSID, RSI, Security type and Password (often empty)
EspIdfBleProvisioningRn.scanNetworks().then(res => {
    // res is an array of detected networks
}).catch(e => {
    console.error(e)
})

// This method is used when is required to provision custom data to custom endpoints
EspIdfBleProvisioningRn.sendCustomData("custom-endpoint", "data").then(resp => {
    // res will be {"success":true}
}).catch(e => {
    console.error(e)
})

// This method is used when is required to provision custom data to custom endpoints
// with the special cavieat that React-Native's bridges to Native can destroy binary data
// encoded as UTF-8 strings. See Example for details. Convert string to JS's Uint8Array, then to an array 
// of strings where each string has the hexidecimal representation of its corresponding byte
// there is a walk through in ./example/App.js
EspIdfBleProvisioningRn.sendCustomDataWithByteData("custom-endpoint",["0", "FF", "52"]).then(resp => {
    // this is worth tweaking, but I have found that the data response
    // is wrapped in some other packaging I have to strip away from
    // the beginning and then JSON parsing works. The Native Backend manages
    // encryption at the session level. ESPRESSIF's libraries default to security_1 (as opposed to 0)
    const data = JSON.parse(resp.data.substring(8));
    ToastAndroid.show(
        'Custom data with byte accuracy provisioned successfully',
        ToastAndroid.LONG,
    );
    console.log(data); // data, likely in 
}).catch(e => {
    console.error(e)
})

// This method is used to provision new wifi credentials on the device
EspIdfBleProvisioningRn.provisionNetwork("SSIS", "PASS").then(resp => {
    // resp will be {"success":true}
}).catch(e => {
    console.error(e)
})

```
<br/>

## Example app

You can find an useful example in this link: [Example app here](https://github.com/manbomb/esp-idf-ble-provisioning-rn/tree/master/example)
<br/><br/>
## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
<br/><br/>
## License

MIT

---
_Source: https://npm.io/package/react-native-esp-idf-ble-provisioning-rn · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
