nRF52 PCA10040 DK printf output via putty

I have the nRF52 PCA10040 DK device, and I’m downloading the code from the online mbed tutorial. I’m using Putty serial port to communicate with the device at 9600 baud rate. I’m trying to print out the elements of the Bluetooth beacon signals I receive from my device using the printf() function. The specific elements I’d like to print out are the manufacturer ID, time in milliseconds I received the signal, and the received signal strength in each advertising channels 37, 38, and, 39. I hope to print them out to the console, so I can have a record of the signal strengths over time.

I’m using the example on I took out some elements that I thought were not useful to me in my goal. I’m receiving the Bluetooth beacon signals in the function “advertisementCallback”, and that’s the place I’m printing the applicationSpecificId, which I thought was the manufacturer ID.

I also used the nRF Connect application the RSSI Viewer plugin, but that does not keep a record of all the RSSI values I get over time.

Does anyone know how to print the elements I mentioned?

I also included the full code in this post.

#include <stdio.h>
#include <events/mbed_events.h>
#include “mbed.h”
#include “ble/BLE.h”

static const int URI_MAX_LENGTH = 18; // Maximum size of service data in ADV packets

static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);

DigitalOut led1(LED1, 1);

void periodicCallback(void){
led1 = !led1; /* Do blinky on LED1 while we’re waiting for BLE events */


  • This function is called every time we scan an advertisement.
    void advertisementCallback(const Gap::AdvertisementCallbackParams_t params){
    struct AdvertisingData_t {
    uint8_t length; /
    doesn’t include itself */
    GapAdvertisingData::DataType_t dataType;
    uint8_t data[1];

    struct ApplicationData_t {
    uint8_t applicationSpecificId[2];
    uint8_t frameType;
    uint8_t advPowerLevels;
    uint8_t uriData[URI_MAX_LENGTH];

    AdvertisingData_t *pAdvData;
    size_t index = 0;
    while(index < params->advertisingDataLen) {
    pAdvData = (AdvertisingData_t *)&params->advertisingData[index];
    ApplicationData_t *pAppData = (ApplicationData_t *) pAdvData->data;
    printf("%x\n", pAppData->applicationSpecificId);
    index += (pAdvData->length + 1);

void bleInitComplete(BLE::InitializationCompleteCallbackContext *params){
BLE& ble = params->ble;
ble_error_t error = params->error;

if (error != BLE_ERROR_NONE) {

if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
} /* scan interval /, 1500 / scan window */);;

void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
BLE &ble = BLE::Instance();<void()>(&ble, &BLE::processEvents));

int main(){
eventQueue.call_every(500, periodicCallback);

BLE &ble = BLE::Instance();


return 0;

From what I remember, you have to place the printf in a separate function which is then called using the eventQueue method so that it does not block the advertisementCallback function.