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

node-conected

v1.0.0

Published

Uma ponte Bluetooth Node.js baseada na sintaxe do html2apk

Readme

node-conected 🚀

Uma ponte Bluetooth Node.js elegante para Linux, inspirada e baseada na exata sintaxe da API Bluetooth do html2apk.

Com ela, você pode criar conexões Bluetooth bidirecionais (Host e Client) de forma transparente, usando Promises, Event Listeners e envio nativo de JSON. O módulo abstrai toda a complexidade do SPP (Serial Port Profile) e do RFCOMM.

Instalação Segura

Por baixo dos panos, o módulo utiliza APIs C++ nativas. Para facilitar a sua vida no Linux, criamos um assistente interativo:

# 1. Instale o pacote
npm install node-conected

# 2. Rode o assistente para instalar os drivers de Bluetooth do Linux (se precisar)
npx node-conected-setup

O instalador tem suporte nativo para Português (PT) e Inglês (EN).

Principais Vantagens

  • Buffer de Stream Inteligente: Diferente do TCP padrão que corta JSONs grandes no meio, o node-conected monta os fragmentos (\n) para garantir que os dados cheguem 100% íntegros.
  • Sintaxe Bilíngue: Trabalha com os métodos originais em Português ou seus atalhos universais em Inglês.
  • Focado no Desenvolvedor: Sem crashes de compilação bloqueantes.

Como usar

1. Criando um Servidor (Host) que escuta

O Host abre a sala e escuta clientes se conectarem.

const bt = require('node-conected');

// 1. Liga o servidor na porta Bluetooth
bt.aoConectarBT((dispositivo) => {
  console.log("Alguém conectou na sala:", dispositivo.nome || dispositivo.id);
});

// 2. Escuta mensagens recebidas (Já chegam convertidas de JSON)
bt.aoReceberDadosBT((dados) => {
  console.log("Recebido do cliente:", dados);
  
  // Respondendo para todos conectados (Broadcast)
  bt.enviarBT({ resposta: "Tudo certo por aqui!" });
});

bt.aoDarErroBT((erro) => {
  console.error("Erro BT:", erro);
});

2. Criando um Cliente que se conecta

O Cliente procura Hosts próximos, conecta em um deles e manda mensagens.

const bt = require('node-conected');

async function iniciar() {
  // Prepara o ouvido para a resposta do Host
  bt.aoReceberDadosBT((dados) => {
    console.log("O Host me respondeu:", dados);
  });

  // 1. Procura dispositivos pareados/visíveis
  const dispositivos = await bt.procurarBT();
  
  if (dispositivos.length > 0) {
    const alvo = dispositivos[0]; // Pegando o primeiro
    
    // 2. Conecta
    await bt.conectarBT(alvo.id);
    
    // 3. Envia os dados nativamente
    await bt.enviarBT({ msg: "Olá Host, cheguei!" });
  }
}

iniciar();

Tabela de Sintaxe (PT / EN)

Você pode misturar ou escolher qualquer um dos idiomas no seu código.

| Português | Inglês (Alias) | O que faz | |---|---|---| | aoConectarBT(callback) | onConnectBT | Salva o callback de conexão e, se chamado no Host, inicia o servidor. | | aoReceberDadosBT(callback) | onReceiveDataBT | Salva o callback que recebe JSON ou Texto quando chega um dado. | | aoDarErroBT(callback) | onErrorBT | Salva o callback de captura de erros Bluetooth. | | await procurarBT() | searchBT | Varre os aparelhos próximos. Retorna Array [{id, nome}]. | | await conectarBT(id) | connectBT | Tenta conectar a um Host SPP específico. | | await enviarBT(json) | sendBT | Envia o JSON. Se for Cliente, manda ao Host. Se for Host, envia a sala. |

Licença

ISC