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

ble-faker

v0.1.0

Published

Scriptable BLE simulation toolchain for React Native development

Downloads

84

Readme

🧬 BLE Live Mock Server

A universal Bluetooth Low Energy (BLE) peripheral emulator powered by mojo.js. This server allows mobile developers to simulate complex hardware behavior by simply editing JSON files in their IDE.

Changes to your mock files are broadcasted in real-time via WebSockets to your React Native app, enabling a "Hot Reload" experience for hardware integration.


✨ Features

  • File-Based GATT Table: Every device is a .json file. No massive, unmanageable config objects.
  • Live Sync: Powered by WebSockets. Save a file in VS Code → App updates instantly.
  • Bidirectional: Supports both reading from the mock and writing back (Mojo can update the JSON on disk).
  • Logic Offloading: Move complex sensor math (heart rate drift, battery curves) from the app to the Node.js server.
  • Universal: Works with any BLE library, but optimized for react-native-ble-plx-mock.

📂 Project Structure

bridge-server-app/
├── mocks/
│   ├── heart-rate-monitors/       # Category folder (example)
│   │   ├── gatt-profile.json            # GATT structure (see below)
│   │   ├── FF-00-11-22-33-02.json    # Instance 1: "Simulated Runner"
│   │   └── AA-BB-CC-DD-EE-99.json    # Instance 2: "Tachycardia Test"
│   └── battery/                   # Category folder (other example)
│       ├── gatt-profile.json
│       └── 01-23-45-67-89-AB.json    # Some battery
├── src/
│   ├── index.ts         # Mojo entry point & WebSocket routing
│   ├── models/          # Mojo models
│   ├── plugins.ts       # Plugin engines (i.e. watches files & broadcasts)
│   └── controllers/     # Handlers for Browser Dashboard & BLE Sync
├── views/               # Mojo view templates go here
├── test/                # Mojo TestUserAgent integration tests
├── dist/                # Production build (ignored by git)
├── config.json          # app configuration
├── .npmrc               # pnpm configuration
├── .oxlintrc.json
├── package.json         # Managed via pnpm
├── pnpm-lock.json       # pnpm's deterministic lockfile
├── vite.config.js
└── tsconfig.json        # Strict TS config for IDE support

🚀 Getting Started

1. Installation

pnpm add -D ble-live-mock-server

2. Initialize Mocks

Create a folder named ble-specs in your project root with a gatt-profile.json:

{
  "serviceUUIDs": ["180D"],
  "services": [
    {
      "uuid": "180D",
      "characteristics": [
        {
          "uuid": "2A37",
          "properties": { "read": true, "notify": true }
        }
      ]
    }
  ]
}```

### 3. Start the Server

# Binds to 0.0.0.0 to allow connections from emulators and physical devices

```shell
npx ble-live-mock -d ./ble-specs -p 58083

The server will start on http://0.0.0.0:58083.

🧠 Logic Engines (.js)

For dynamic behavior, create a .js file matching a MAC address (XX-XX-XX-XX-XX-XX.json) or device ID (myId.json), inside the category folder.

Input: state (current data), event (start | tick | notify) Output: Array<[UUID, Base64Value]> (Deltas to apply)

export default function(state, event) {
  if (event.kind === 'tick') {
    const hr = Math.floor(60 + Math.random() * 5);
    return [['2A37', Buffer.from([0, hr]).toString('base64')]];
  }
  return [];
}

🛡️ Sandbox Security

Scripts run in a node:vm isolated context. They cannot access process, filesystem, or network. They are pure functions designed to safely simulate hardware state transitions.

📱 React Native Integration

To connect your app to the live mock, use the WebSocket bridge. It automatically detects your Metro server's IP to ensure connectivity on both physical devices and emulators.

import { NativeModules } from "react-native";
import { ConnectToBridge } from "react-native-ble-mocker";
import { MockBleManager } from "react-native-ble-plx-mock";

const getWsUrl = () => {
  // Extract the host from the Metro bundle URL (handles localhost vs LAN IP)
  const scriptURL = NativeModules.SourceCode.scriptURL;
  if (!scriptURL) return "ws://localhost:58083/ble-bridge";

  const host = scriptURL.split("://")[1].split(":")[0];
  return `ws://${host}:58083/ble-bridge`;
};

// Connect and pipe into your mock manager
ConnectToBridge(MockBleManager, getWsUrl);

🛠 Development Commands

| Command | Description | | :----------- | :---------------------------------------------------- | | pnpm dev | Starts Mojo server with --watch for logic changes. | | pnpm test | Runs native Node.js tests for the GATT logic. | | pnpm build | Compiles TypeScript to the dist/ folder using Vite. | | pnpm lint | Runs oxlint for high-speed code quality checks. |


🤝 Contributing

This project is built with mojo.js. As a community-driven tool, feel free to submit PRs focusing on the reactivity engine, file-watcher performance, or adding new BLE service templates.

License: MIT