Hello,
I'm using a project derived from Simple Central but heavily modified. I'm to the point where I can read a characteristic value correctly and reliably. The problem is that I can't seem to get any notifications to come in.
During initialization, in SimpleCentral_init() the following is called:
// Register to receive incoming ATT Indications/Notifications
GATT_RegisterForInd(selfEntity);
My understanding is that this registers the client for notifications.
When the server/peripheral changes values, I don't see any GATT messages received. (See code below.) Do I have to register the characteristic or service? Am I missing something?
I know that the server / peripheral sends notifications because I see them using the LightBlue app on my iPhone.
Jason
Code below:
---------------------------------------------------------------------------------------------------
static void SimpleCentral_processGATTMsg(gattMsgEvent_t *pMsg)
{
Log_info1("The GATT Message has method of type %x.", pMsg->method);
// First, is the connection currently active?
if (linkDB_Up(pMsg->connHandle))
{
// See if GATT server was unable to transmit an ATT response
if (pMsg->hdr.status == blePending)
{
// No HCI buffer was available. App can try to retransmit the response
// on the next connection event. Drop it for now.
}
else if ((pMsg->method == ATT_READ_RSP) ||
((pMsg->method == ATT_ERROR_RSP) &&
(pMsg->msg.errorRsp.reqOpcode == ATT_READ_REQ)))
{
if (pMsg->method == ATT_ERROR_RSP)
{
Log_info0("Error Reading Characteristic.");
}
else
{
Log_info0("Characteristic successfully read.");
Skydda_readCharValue(pMsg);
uint16_t value;
//value = (pMsg->msg.readRsp.pValue[1] << 8) | pMsg->msg.readRsp.pValue[9];
value = Skydda_readCharValue(pMsg);
// Log_info2("The data is %x and the length is %d.", pMsg->msg.readRsp.pValue, pMsg->msg.readRsp.len);
Log_info2("The data is %x and the length is %d.", value, pMsg->msg.readRsp.len);
}
}
else if ((pMsg->method == ATT_WRITE_RSP) ||
((pMsg->method == ATT_ERROR_RSP) &&
(pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ)))
{
if (pMsg->method == ATT_ERROR_RSP)
{
}
else
{
}
}
else if (pMsg->method == ATT_FLOW_CTRL_VIOLATED_EVENT)
{
// ATT request-response or indication-confirmation flow control is
// violated. All subsequent ATT requests or indications will be dropped.
// The app is informed in case it wants to drop the connection.
}
else if (pMsg->method == ATT_MTU_UPDATED_EVENT)
{
// MTU size updated
}
else if (pMsg->method == ATT_HANDLE_VALUE_NOTI) // <= this never happens.
{
Log_info0("We received a notification event.");
}
else if (discState != BLE_DISC_STATE_IDLE)
{
Log_info0("BLE_DISC_STATE_IDLE");
SimpleCentral_processGATTDiscEvent(pMsg);
}
} // else - in case a GATT message came after a connection has dropped, ignore it.
// Needed only for ATT Protocol messages
GATT_bm_free(&pMsg->msg, pMsg->method);
}