bleancs add performAction
This commit is contained in:
1 parent
c0dedf4f37
commit
0e65819100
3 files changed
+34
No files matched your search
@@ -110,6 +110,13 @@ void ancs_notification_callback(ancsNotification_t* notif)
|
||||
// Serial.printf("%-20s | ", buffer);
|
||||
|
||||
Serial.println();
|
||||
|
||||
// Automatically accept incoming call using perform Action
|
||||
if ( notif->categoryID == ANCS_CAT_INCOMING_CALL && notif->eventID == ANCS_EVT_NOTIFICATION_ADDED)
|
||||
{
|
||||
Serial.println("Incoming accepted");
|
||||
bleancs.performAction(notif->uid, ANCS_ACTION_POSITIVE);
|
||||
}
|
||||
}
|
||||
|
||||
void connect_callback(void)
|
||||
|
||||
@@ -163,6 +163,20 @@ typedef struct ATTR_PACKED
|
||||
|
||||
VERIFY_STATIC( sizeof(get_notif_attr_t) == 8);
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
// Cortex M4 can access unaligned memory
|
||||
uint8_t cmd;
|
||||
uint32_t uid;
|
||||
uint8_t actionid;
|
||||
}perform_action_t;
|
||||
|
||||
VERIFY_STATIC( sizeof(perform_action_t) == 6);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/*
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
uint16_t BLEAncs::getAttribute(uint32_t uid, uint8_t attr, void* buffer, uint16_t bufsize)
|
||||
{
|
||||
VERIFY ( attr < ANCS_ATTR_INVALID, 0);
|
||||
@@ -277,6 +291,18 @@ uint16_t BLEAncs::getAppAttribute(const char* appid, uint8_t attr, void* buffer,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BLEAncs::performAction(uint32_t uid, uint8_t actionid)
|
||||
{
|
||||
perform_action_t action =
|
||||
{
|
||||
.cmd = ANCS_CMD_PERFORM_NOTIFICATION_ACTION,
|
||||
.uid = uid,
|
||||
.actionid = actionid
|
||||
};
|
||||
|
||||
return sizeof(perform_action_t) == _control.write_resp(&action, sizeof(perform_action_t));
|
||||
}
|
||||
|
||||
void BLEAncs::_handleNotification(uint8_t* data, uint16_t len)
|
||||
{
|
||||
if ( len != 8 ) return;
|
||||
|
||||
@@ -145,6 +145,7 @@ class BLEAncs : public BLECentralService
|
||||
|
||||
uint16_t getAttribute(uint32_t uid, uint8_t attr, void* buffer, uint16_t bufsize);
|
||||
uint16_t getAppAttribute(const char* appid, uint8_t attr, void* buffer, uint16_t bufsize);
|
||||
bool performAction(uint32_t uid, uint8_t actionid);
|
||||
|
||||
protected:
|
||||
virtual void disconnect(void);
|
||||
|
||||
Reference in new issue
Block a user