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);
        }
    }
}
Related