Hello I am a new user in the BLE world.
I am using the nRF52 DK board and trying to program it via PlatformIO by visual studio code i.e coding with arduino programming C++. I tried flasing the LED blink code and it works fine. But when I include the BLE feature and dump a code onto the board, it says uploaded successfully but the mobile app nRF connect dose not identify the Nordic nRF52 BLE device.
The code I uploaded was
#include <Arduino.h> #include <SPI.h> #include <BLEPeripheral.h> BLEPeripheral ledPeripheral = BLEPeripheral(); BLEService ledService = BLEService("19b10000e8f2537e4f6cd104768a1214"); BLECharCharacteristic ledCharacteristic = BLECharCharacteristic("19b10001e8f2537e4f6cd104768a1214", BLERead | BLEWrite); void setup() { pinMode(LED_BUILTIN, OUTPUT); ledPeripheral.setAdvertisedServiceUuid(ledService.uuid()); ledPeripheral.addAttribute(ledService); ledPeripheral.addAttribute(ledCharacteristic); ledPeripheral.setLocalName("Nordic NRF52 DK"); ledPeripheral.begin(); } void loop() { BLECentral central = ledPeripheral.central(); if (central) { while (central.connected()) { if (ledCharacteristic.written()) { if (ledCharacteristic.value()) { digitalWrite(LED_BUILTIN, HIGH); } else{ digitalWrite(LED_BUILTIN, LOW); } } } } }
Please guide me on this.