npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-bluetooth-classic

v1.4.3

Published

A React Native Bluetooth provider using react-native-bluetooth-classic

Downloads

35

Readme


rn-native-bluetooth-classic

rn-bluetooth-classic is a React Native package that provides a Bluetooth context and hooks for managing Bluetooth functionality in your app. It handles permissions, device scanning, connection management, and data reception.

Installation

You can install rn-bluetooth-classic via npm or yarn:

npm install rn-bluetooth-classic

or

yarn add rn-bluetooth-classic

Dependencies

rn-bluetooth-classic uses react-native-bluetooth-classic under the hood to scan and connect to devices and only acts as a wrapper on top to make it easier to use.

npm install react-native-bluetooth-classic

or

yarn add react-native-bluetooth-classic

Usage

1. Import the BluetoothProvider and wrap your app with it in your root component:

import { BluetoothProvider } from 'rn-bluetooth-classic';

const App = () => {
  return (
    <BluetoothProvider>
      <YourApp />
    </BluetoothProvider>
  );
};

2. Use the useBluetooth hook in your components to access Bluetooth functionality:

import { useBluetooth } from 'rn-bluetooth-classic';

const YourComponent = () => {
  const { isScanning, devices, scanDevices, connectToDevice } = useBluetooth();

  // Your component logic here...
};

Use with Expo

If you are using Expo and want to integrate rn-bluetooth-classic, you can use the with-rn-bluetooth-classic Expo plugin maintained by amitferman. This plugin helps with auto-configuration of permissions and protocols.

Expo Plugin

amitferman has released and maintains a with-rn-bluetooth-classic Expo plugin to get things working.

Expo Installation

You can install react-native-bluetooth-classic and with-rn-bluetooth-classic from npm using Expo's expo install command:

expo install react-native-bluetooth-classic with-rn-bluetooth-classic

Configure app.json or app.config.json

After installation, configure your app.json or app.config.json with the following settings:

{
  "plugins": [
    ["with-rn-bluetooth-classic",
      {
        "peripheralUsageDescription": "Allow myDevice to check bluetooth peripheral info",
        "alwaysUsageDescription": "Allow myDevice to always use bluetooth info",
        "protocols": [
          "com.myCompany.p1",
          "com.myCompany.p2"
        ]
      }
    ]
  ]
}

Make sure to replace "com.myCompany.p1" and "com.myCompany.p2" with your own protocol identifiers.

Features

  • Request Bluetooth permissions
  • Scan for nearby Bluetooth devices
  • Connect to a Bluetooth device
  • Receive data from connected devices

Example

For a complete example of how to use rn-bluetooth-classic, check out the example directory in this repository.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you find any bugs or want to suggest improvements.

License

This package is licensed under the MIT License. See the LICENSE file for details.


Feel free to customize this template with additional information specific to your package. Make sure to replace placeholders like YourApp with actual names or values.