i am hacking the uart service code.
the central talks to the gatt client instead of the server.
this allows the two modules to connect the uart service.
it works for the communication from central to peripheral.
but the central receives nothing. the event ondatawriten
for the gattclient always delivers 0 as data length. this means
the gatt client receives something ...
need more time for hacking ...
Hi Robert, all,
Following on from a few points which you made.
I have two nrf51822 platforms, both running an application that has a BLE UART service and also a custom BLE service ( similar to ButtonSense ) which I use as a means of passing control characteristics and a status.
I connect to one device from the Nordic toolbox UART app and then pass it a command over the UART to scan and connect to peripherals. While doing this I am writing to the UART serice rx characteristic as a means of debug and then I get the prints in the app. I am familiar with the notification mechanism by which the rx characteristic notifies the app of a write to that characteristic.
My firmware works correctly in that one nrf51822 device operating in CENTRAL mode can control another nrf51822 as peripheral and the nrf51822 operating in CENTRAL is also still connected as a PERIPHERAL to the app. However, as soon as I call connect I no longer get any UART notifications back on the Rx characteristic, however the writes I make to the Tx characteristic to send data to the firmware from the Nordic app do seem to work.
So in my scanning callback. I see the two BLE_UART_WRITEs ( macro resolves to pUartService->writeString() ) and then call connect.
void scanAdvertCallback (const Gap::AdvertisementCallbackParams_t *params)
{
BLE_UART_WRITE ("Ad[%02x %02x %02x %02x %02x %02x]\r\n", // I SEE THIS UART WRITE IN THE NORDIC APP
params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0] );
BLE_UART_WRITE ("Rssi %d, %u, AdType %u\r\n",
params->rssi, params->isScanResponse, params->type ); // AND THIS ONE...
m_ble.gap().connect( params->peerAddr, Gap::ADDR_TYPE_RANDOM_STATIC, NULL, NULL );
}
and in my connection callback...
void connectionCallback ( const Gap::ConnectionCallbackParams_t *params )
{
if (params->role == Gap::CENTRAL)
{
BLE_UART_WRITE ( "Perip Conn %d\n", params->handle ); // BUT AFTER I HAVE CONNECTED TO THE PERIPHERAL I DON't SEE THIS ONE.
gCtrl.hPeriphConnHandle = params->handle;
m_ble.gattClient().onServiceDiscoveryTermination( discTermCallback );
m_ble.gattClient().launchServiceDiscovery( params->handle, servDiscCallback, charDiscCallback );
}
else if (params->role == Gap::PERIPHERAL)
{ ... etc
My connection to the peripheral succeeds however I never see anymore BLE_UART_WRITEs in the Nordic app.
Any ideas, I have a recollection about reading about something like this in the past but I cannot find the thread after soom searching. Is this some how related to the scope in which I am operating, for example if I am receiving a BLE connectionback in CENTRAL role and write to the UART service am I writing to a different UART service context than if I am writing in PERIPHERAL ROLE?
Cheers,
Allen
Your LED peripheral blinking endlessly is the correct behaviour for this demo. It must mean that you've connected and are able to read and write as a client.