Code Monkey home page Code Monkey logo

Comments (9)

deadprogram avatar deadprogram commented on September 19, 2024

Anyone else also trying this same sort of thing?

from ble.

deadprogram avatar deadprogram commented on September 19, 2024

Looks like #36 has the same problem with the call to unix.Read() blocking.

from ble.

deadprogram avatar deadprogram commented on September 19, 2024

A little more info: I am able to do the same thing using Noble, and it is able to connect both peripherals. So it is not a hardware problem.

Here is my Noble node.js code:

var noble = require('noble');

var peripheralIdOrAddress = process.argv[2].toLowerCase();
var peripheralIdOrAddress2 = process.argv[3].toLowerCase();

var p1, p2;
var counter = 0;

noble.on('stateChange', function(state) {
  if (state === 'poweredOn') {
    noble.startScanning();
  } else {
    noble.stopScanning();
  }
});

noble.on('discover', function(peripheral) {
  if (peripheral.id === peripheralIdOrAddress || peripheral.address === peripheralIdOrAddress ||
      peripheral.id === peripheralIdOrAddress2 || peripheral.address === peripheralIdOrAddress2) {

   counter++;
   if (counter > 1) {
      noble.stopScanning();
      p2 = peripheral;
      connect(p1);
      connect(p2);
   } else {
      p1 = peripheral;
   }

    console.log('peripheral with ID ' + peripheral.id + ' found');
    var advertisement = peripheral.advertisement;

    var localName = advertisement.localName;
    var txPowerLevel = advertisement.txPowerLevel;
    var manufacturerData = advertisement.manufacturerData;
    var serviceData = advertisement.serviceData;
    var serviceUuids = advertisement.serviceUuids;

    if (localName) {
      console.log('  Local Name        = ' + localName);
    }

    if (txPowerLevel) {
      console.log('  TX Power Level    = ' + txPowerLevel);
    }

    if (manufacturerData) {
      console.log('  Manufacturer Data = ' + manufacturerData.toString('hex'));
    }

    if (serviceData) {
      console.log('  Service Data      = ' + serviceData);
    }

    if (serviceUuids) {
      console.log('  Service UUIDs     = ' + serviceUuids);
    }

    console.log();
  }
});

function connect(peripheral) {
  peripheral.connect(function(error) {
     console.log("connected to ", peripheral.uuid)
  });
}

This code is able to run without a problem:

$ node ./examples/multi.js 984fee0f386a f3f26d557108
peripheral with ID 984fee0f386a found
  Local Name        = FIRMATA
  Service Data      = 
  Service UUIDs     = 6e400001b5a3f393e0a9e50e24dcca9e

peripheral with ID f3f26d557108 found
  Local Name        = BB-7108
  TX Power Level    = -10
  Manufacturer Data = 3330
  Service Data      = 
  Service UUIDs     = 22bb746f2ba075542d6f726568705327

connected to  984fee0f386a
connected to  f3f26d557108

I've attached the log from the Noble connection from the equivalent ble code, in case anyone wants to take look and see if there is something I've missed.

n2.txt

from ble.

ziflex avatar ziflex commented on September 19, 2024

@deadprogram probably, I will need to close that issue. I have not touched my app which uses BLE, but the last time I ran it it was working well. Looks like the issue was in BlueZ. Plus, on MacOS it worked just fine.

from ble.

deadprogram avatar deadprogram commented on September 19, 2024

I was recently experimenting with the latest ble from the go-ble fork on a newer system (newer kernel, newer BT adaptor), and I was able to connect to multiple devices without problem. Not sure what the root cause is still of those 2, but I thought I would at least update this issue.

from ble.

Hodapp87 avatar Hodapp87 commented on September 19, 2024

I am running into this as well. https://github.com/paypal/gatt is able to handle multiple connections, so it's not the hardware (but I have other issues with that code).

@deadprogram What is the go-ble fork? Do you have a URL?

from ble.

roylee17 avatar roylee17 commented on September 19, 2024

Just curious. Which BLE chip are you all using?

I had problem with CSR chip long time ago, so I have been using Broadcom chip for a long time.

Two different parties I co-worked with recently happened to have problem with using multiple dongles at the same time, and they were all CSR chips.

They are technically two different issues, but hardware may play a part here, too.

from ble.

deadprogram avatar deadprogram commented on September 19, 2024

Hi @Hodapp87 that fork is located here https://github.com/go-ble/ble

@roylee17 is correct about specific hardware sometimes playing a role, in particular older devices.

However I suspect that your issue is likely the same as serveral of mine were. I found that one must be using a newer Linux kernel for ble to work well. I current use 4.9+ with various hardware, and have had much better success, sometime with the exact same hardware, hence I attribute this to newer kernel versions.

Anyhow, hope that helps!

from ble.

Hodapp87 avatar Hodapp87 commented on September 19, 2024

Okay - ignore what I just wrote.

I just tried the code example up top, and as far as I can tell it establishes multiple connections with no trouble (tried on both currantlabs/ble and go-ble/ble). The issue I was having earlier seems to be unrelated - I didn't realize I needed multiple contexts for multiple connections.

I am on a CSR chip and Linux kernel 4.9.86.

from ble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.