This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Connecting to the nrF52 DK BLE through linux whith pygatt

Hello,

I'm trying to connect my Linux computer to the nrF52 DK card using BLE. I'm connecting my Bluetooth chip to nrF52 and I want to display "hello" on the serial interface of nrF52 DK

The BLE connexion and pairing is working with gatttool and bluetoothctl.

With gatttool and the command line "char-desc" I'm able to get the list of the services UUIDs.

I tried some of the TX UUID I found but it seems like they are not the one I'm supposed to use.

I would like to know which service is the correct TX service to send "Hello" from the nrf52DK and receive it on Linux or if there is something wrong in my code.

Here is the code on the nrF52 DK side :

#include <Arduino.h>
#include <SPI.h>
#include <BLEPeripheral.h>

BLEPeripheral ledPeripheral = BLEPeripheral();

BLEBondStore bond = BLEBondStore();

BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214");
BLECharCharacteristic ledCharacteristic = BLECharCharacteristic("19b10001e8f2537e4f6cd104768a1214", BLERead | BLEWrite);

void setup()
{
    Serial.begin(9600);
    pinMode(LED_BUILTIN, OUTPUT);

    ledPeripheral.setAdvertisedServiceUuid(ledService.uuid());
    ledPeripheral.addAttribute(ledService);
    ledPeripheral.addAttribute(ledCharacteristic);
    ledPeripheral.setLocalName("Nordic NRF52 DK");
    ledPeripheral.setConnectable(true);
    ledPeripheral.setBondStore(bond);
    ledPeripheral.begin();
}
void loop()
{
    BLECentral central = ledPeripheral.central();

    if (central)
    {
        while (central.connected())
        {
            Serial.println('Hello');
            delay(500);
        }
    }
}
Parents
  • Hi,

    I'm not sure what pygatt have to do with your question, and I'm not sure I understand what you are trying to do.

    It looks like your code will setup a BLE peripheral, wait for a BLE central to connect, and when it is connected, print "Hello" on the Serial/UART interface of the nRF52-DK twice evey second. Are you not able to see this message?

    You should not need any UUIDs for this to work, but if you only want to write "Hello" when the characteristics is written, you should check out the example code in the Arduino documentation.

    Best regards,

    Jørgen

Reply
  • Hi,

    I'm not sure what pygatt have to do with your question, and I'm not sure I understand what you are trying to do.

    It looks like your code will setup a BLE peripheral, wait for a BLE central to connect, and when it is connected, print "Hello" on the Serial/UART interface of the nRF52-DK twice evey second. Are you not able to see this message?

    You should not need any UUIDs for this to work, but if you only want to write "Hello" when the characteristics is written, you should check out the example code in the Arduino documentation.

    Best regards,

    Jørgen

Children
No Data