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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oesp/transport-ble-gatt

v8.0.0

Published

OESP BLE GATT Transport (P2P offline)

Readme

@oesp/transport-ble-gatt

Transport OESP via BLE GATT (Central <-> Peripheral) avec support asynchrone et fragmentation.

Installation

npm install @oesp/transport-ble-gatt

Fonctionnalités

  • Communication P2P Offline : Échange de données sans internet.
  • Fragmentation Automatique : Gestion transparente du MTU BLE.
  • Protocole Stop-and-Wait : Fiabilité accrue via acquittements (ACK).
  • Opérations Asynchrones : Utilisation de Promise pour toutes les opérations I/O.
  • Crypto Agnostique : Injection de la fonction de hachage SHA-256 pour compatibilité multi-plateforme (Node.js, React Native, Browser).

Utilisation (Central)

Le mode Central est généralement utilisé par l'application mobile qui scanne et se connecte au périphérique.

import { OESPBleGattTransport } from '@oesp/transport-ble-gatt';
import { MyBleLink } from './MyBleLink'; // Votre implémentation de BleGattLink
import { sha256 } from 'js-sha256'; // Ou autre provider

// 1. Initialiser le transport avec le provider SHA-256
const transport = new OESPBleGattTransport({
  sha256: async (data) => new Uint8Array(sha256.arrayBuffer(data))
});

const link = new MyBleLink();

try {
  // 2. Connexion (géré par votre implémentation Link)
  await link.connect('DEVICE_UUID');

  // 3. Envoi d'un token OESP de manière asynchrone
  // La méthode gère la fragmentation et les ACK automatiquement
  await transport.sendToken(oespTokenBytes, link);
  console.log("Token envoyé avec succès !");

} catch (err) {
  console.error("Erreur de transport:", err);
}

Utilisation (Peripheral)

Le mode Peripheral est utilisé par l'appareil IoT ou le receveur.

const transport = new OESPBleGattTransport({
  sha256: async (data) => new Uint8Array(sha256.arrayBuffer(data))
});
const link = new MyBleLink(); // Implémentation côté périphérique

// Boucle de réception asynchrone
transport.receiveLoop(link, async (token) => {
  console.log("Token OESP complet reçu:", token);
  // Traitement du token...
});

Interface BleGattLink

Vous devez fournir une implémentation de l'interface BleGattLink adaptée à votre environnement (ex: react-native-ble-plx ou noble).

interface BleGattLink {
  // MTU négocié (doit être > 23 pour de meilleures performances)
  mtu: number;
  
  // Écrit des données sur la caractéristique RX du pair
  write(data: Uint8Array): Promise<void>;
  
  // Lit des données depuis la caractéristique TX du pair
  read(): Promise<Uint8Array>;
  
  // Ferme la connexion
  close(): Promise<void>;
}

Notes Techniques

  • MTU & Fragmentation : Le transport découpe les messages OESP (souvent > MTU) en trames. Assurez-vous que link.mtu reflète le MTU réel négocié.
  • Timeout : Un timeout est appliqué si un ACK n'est pas reçu à temps.
  • Android : Nécessite les permissions BLUETOOTH_SCAN et BLUETOOTH_CONNECT.