Closed jacobmh1177 closed 7 years ago
Update I changed the following code to make it little-endian but it still doesn't work:
byte buffer[8];
long uid = notification.notificationUid;
int m_size = (int)MESSAGE_SIZE;
buffer[0] = 0x00;//ANCS_COMMAND_GET_NOTIF_ATTRIBUTES;
buffer[4] = (uid >> 24) & 0xFF;
buffer[3] = (uid >> 16) & 0xFF;
buffer[2] = (uid >> 8) & 0xFF;
buffer[1] = uid & 0xFF;
buffer[5] = 0x00; //ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE;
Thanks for the quick response! I'm pretty new to working with BLE, but I couldn't find buffer.writeUint8/32 in the arduino library. Could you help me understand how to apply the node code to arduino?
@jacobmh1177 Hi jacob, did you solve the problem with the ANCS Control Point? I'm interested to write to ANCS Control Point too. Any hint on how to do that? Thanks
@claudioarduino I haven't gotten it to work yet and I'm stuck with the code I have above. I think it should theoretically work. I've also checked to make sure I'm subscribed to the ANCS data source characteristic. Maybe it has to do with the order I subscribe to characteristics? I'm hoping @sandeepmistry can give me some more insight into this bug
I'm hoping @sandeepmistry can give me some more insight into this bug
I don't think it's a bug in the library ...
Serial.println(ancsControlPointCharacteristic.write((const unsigned char*)buffer, 9));
Why is the 9
here? The buffer size should be either 6 or 8.
Closing this for now, we can always re-open if this was not the problem.
Yea I noticed this when I was going back through my code and changed that to an 6 or 8 and it still didn't work.
@jacobmh1177 Hi jacob, how do you update the values on the ANCS Data Source, after you send the command to the ANCS Control Point? Did you solve the problem?
@claudioarduino I have not solved the issue of using ANCS using this library but would love to collaborate. The way ANCS works is that you subscribe to the Notification Source characteristic that is updated whenever your apple device receives a notification. The Notification Source gives you meta data about the notification, but the most important thing is the Notification UID. If you want to see more information about the notification (i.e. The body of the text message) you need to send back a specifically formatted command buffer to the Control Point characteristic. If the buffer is correctly formatted, the requested information will be written to the Data Source. https://developer.apple.com/library/content/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html
@jacobmh1177 Hi jacob, I tried to send CommandIDPerformNotificationAction through the Control point, in this case it works, instead when I try to send ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES the ancsControlPointCharacteristic.write(buffer, buffer length) returns true, but I have not response from the IOS device. It seems that there's something wrong on the ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES or something must be enabled on the IOS device? Thanks for your help.
@claudioarduino that's awesome! Could you send me the code you got working for CommandIDPerformNotificationAction? I'll look into configuring the iPhone
@jacobmh1177 Hi jacob, the code for notification action is:
/ PERFORM_NOTIFICATION_ACTION / byte buffer[6]; buffer[0] = ANCS_COMMAND_ID_PERFORM_NOTIF_ACTION; //(0x02) buffer[4] = (uid >> 24) & 0xFF; buffer[3] = (uid >> 16) & 0xFF; buffer[2] = (uid >> 8) & 0xFF; buffer[1] = uid & 0xFF; buffer[5] = ANCS_ACTION_ID_POSITIVE; //(0x00)
Serial.println("Perform action buffer "); BLEUtil::printBuffer(buffer, 6); Serial.println(); Serial.println(ancsControlPointCharacteristic.write((const unsigned char*)buffer, 6));
This is the buffer I used to perform a notification action. This code works, when i try to call my Iphone it answers, but i'm not still able to see the notification attributes. I tried with your code for the notification attribute, the control point is ok but the data source doesn't works. The cose id:
/ GET_NOTIFICATION_ATTRIBUTE / byte buffer[8]; buffer[0] = ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES; buffer[4] = (uid >> 24) & 0xFF; buffer[3] = (uid >> 16) & 0xFF; buffer[2] = (uid >> 8) & 0xFF; buffer[1] = uid & 0xFF; buffer[5] = ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE; buffer[6] = 20; //ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE; buffer[7] = 0; //ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE; BLEUtil::printBuffer(buffer, 8); Serial.println("Sending notification attribute buffer "); Serial.println(); Serial.println(ancsControlPointCharacteristic.write((const unsigned char*)buffer, 8));
Let me know if you make any progress. Thanks
@jacobmh1177 Hi jacob, I found what's the problem. You have to add
if (ancsDataSourceCharacteristic.canSubscribe()) {
ancsDataSourceCharacteristic.subscribe();
Serial.println("Subscribed to Data Source");
}
before to define the buffer structure, then put the buffer structure for the command and then
Serial.println(ancsControlPointCharacteristic.write((const
unsigned char)buffer, 8)); ` , it works.
Now I'm working on the Alert Notification Service to make a sort of ANCS for Android. Any idea on how it works? Thanks
@jacobmh1177 Hi jacob, I found what's the problem. You have to add
if (ancsDataSourceCharacteristic.canSubscribe()) { ancsDataSourceCharacteristic.subscribe(); Serial.println("Subscribed to Data Source"); } before to define the buffer structure, then put the buffer structure for the command and then
Serial.println(ancsControlPointCharacteristic.write((const
unsigned char)buffer, 8)); ` , it works.Now I'm working on the Alert Notification Service to make a sort of ANCS for Android. Any idea on how it works? Thanks
I have the same issue. Where is the problem?
void ancsNotificationSourceCharacteristicValueUpdated(BLECentral& central, BLERemoteCharacteristic& characteristic) {
struct AncsNotification notification;
memcpy(¬ification, characteristic.value(), sizeof(notification));
if (ancsDataSourceCharacteristic.canSubscribe()) { ancsDataSourceCharacteristic.subscribe();
}byte buffer[8]; unsigned long uid = notification.notificationUid;
buffer[0] = 0; buffer[4] = (uid >> 24) & 0xFF; buffer[3] = (uid >> 16) & 0xFF; buffer[2] = (uid >> 8) & 0xFF; buffer[1] = uid & 0xFF; buffer[5] = 1; buffer[6] = 19; buffer[7] = 0;ancsControlPointCharacteristic.write((const unsigned char*)buffer, 8);
}
Hi everyone, I'm trying to extend the ANCS example to get notification information (app info, message content, etc.). After reading Apple's documentation it looks like you have to send the ANCS Control Point a specially formatted command buffer to ask for notification information, and if the command buffer is correctly formatted then ANCS will respond using the Data Source characteristic. When I write to the control point, ancsControlPointCharacteristic.write(buffer, buffer length) returns true, but I'm not getting any response on the Data Source characteristic. Any advice on where I'm going wrong? My code for this is pasted below: