Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
Unable to get central Device Name via Web-Bluetooth API

I am trying to fetch the central device name where central is Javascript based web-app and pheripheral is Nano ble 33.

I am using web-bluetooth API and I am able to get pheripheral device name following this enter link description here

and on the other hand, I am able to get the central address using central.address() but I am getting nothing when I am using central.deviceName() or central.localName().

I am wondering where should I setDeviceName() in central. Is it required ?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

According to arduino example at https://docs.arduino.cc/retired/archived-libraries/CurieBLE#example-1, it seems like you should be able to get the BLECentral with the code below:

void loop() {
  // listen for BLE peripherals to connect:
  BLECentral central = blePeripheral.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address());
  }
}

However, BLECentral does not allow you get the central device name information according to https://github.com/arduino/ArduinoCore-arc32/blob/master/libraries/CurieBLE/src/BLECentral.h

class BLECentral {
  public:
    bool connected(void); // is the central connected
    
    const char* address(void) const; // address of the Central in string form

    bool disconnect(void); // Disconnect the central if it is connected
    void poll(void); // Poll the central for events
...

I'd suggest you use the address and use "Central 00:11:22:33:44:55" for the name if that's required for you.

To be clear, Web Bluetooth does not allow you to get the Central device name. It allows web pages running in the Central role, to connect to GATT Servers over either a Bluetooth connection.

Having said that, nothing prevents you though to have a custom Bluetooth Characteristic on your BLE peripheral that returns the device address of the Central as a value so that you can access it from the web page. See JS example below:

const yourServiceUuid = 0x1234;
const yourCharacteristicUuid = 0x5678;

const device = await navigator.bluetooth.requestDevice({
    // filters: [...] <- Prefer filters to save energy & show relevant devices.
    acceptAllDevices: true,
    optionalServices: [yourServiceUuid]});
const server = await device.gatt.connect();
const service = await server.getPrimaryService(yourServiceUuid);
const characteristic = await service.getCharacteristic(yourCharacteristicUuid);

const value = await characteristic.readValue();
const decoder = new TextDecoder('utf-8');
console.log(`> Central name: "Central ${decoder.decode(value)}"`);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda