Skip to content

Commit

Permalink
Enable unicast sends to bindings in src/app
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Oct 28, 2020
1 parent 49f05f5 commit 2302752
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool emberAfDoorLockClusterSetWeekdayScheduleCallback(uint8_t scheduleId, uint16
if (rfProgrammingEventMask & BIT(0))
{
emberAfFillCommandDoorLockClusterProgrammingEventNotification(0x01, 0x00, userId, &userPin, 0x00, 0x00, 0x00, &userPin);
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();
}

return true;
Expand Down
10 changes: 5 additions & 5 deletions src/app/clusters/door-lock-server/door-lock-server-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool emberAfDoorLockClusterSetPinCallback(uint16_t userId, uint8_t userStatus, u
emberAfFillCommandDoorLockClusterProgrammingEventNotification(
EMBER_ZCL_DOOR_LOCK_EVENT_SOURCE_RF, EMBER_ZCL_DOOR_LOCK_PROGRAMMING_EVENT_CODE_PIN_ADDED, userId, pin, userType,
userStatus, 0 /*emberAfGetCurrentTime() #2507*/, pin);
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();
}

return true;
Expand Down Expand Up @@ -334,12 +334,12 @@ bool emberAfDoorLockClusterClearPinCallback(uint16_t userId)
if ((rfProgrammingEventMask & BIT(2)) && !status)
{
emberAfFillCommandDoorLockClusterProgrammingEventNotification(0x01, 0x03, userId, &userPin, 0x00, 0x00, 0x00, &userPin);
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();
}
else if ((rfProgrammingEventMask & BIT(0)) && status)
{
emberAfFillCommandDoorLockClusterProgrammingEventNotification(0x01, 0x00, userId, &userPin, 0x00, 0x00, 0x00, &userPin);
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();
}

return true;
Expand Down Expand Up @@ -532,7 +532,7 @@ bool emberAfDoorLockClusterLockDoorCallback(uint8_t * PIN)
emberAfFillCommandDoorLockClusterOperationEventNotification(0x01, 0x03, userId, PIN, 0x00, PIN);
}
}
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();

return true;
}
Expand Down Expand Up @@ -570,7 +570,7 @@ bool emberAfDoorLockClusterUnlockDoorCallback(uint8_t * pin)
emberAfFillCommandDoorLockClusterOperationEventNotification(EMBER_ZCL_DOOR_LOCK_EVENT_SOURCE_RF,
EMBER_ZCL_DOOR_LOCK_OPERATION_EVENT_CODE_UNLOCK, userId, pin,
0 /*emberAfGetCurrentTime() #2507 */, pin);
// SEND_COMMAND_UNICAST_TO_BINDINGS();
SEND_COMMAND_UNICAST_TO_BINDINGS();
}

return true;
Expand Down
3 changes: 1 addition & 2 deletions src/app/clusters/door-lock-server/door-lock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,14 @@ bool emAfPluginDoorLockServerCheckForSufficientSpace(uint8_t spaceReq, uint8_t s

// Critical Message Queue
// If the Critical Message Queue Plugin is available, use it for event notifications
/* Replace SEND_COMMAND_UNICAST_TO_BINDINGS #2504
#ifdef EMBER_AF_PLUGIN_CRITICAL_MESSAGE_QUEUE
#include "../critical-message-queue/critical-message-queue.h"
#define SEND_COMMAND_UNICAST_TO_BINDINGS() \
emberAfSendCommandUnicastToBindingsWithCallback(emberAfPluginCriticalMessageQueueEnqueueCallback)
#else
#define SEND_COMMAND_UNICAST_TO_BINDINGS() emberAfSendCommandUnicastToBindings()
#endif
*/

// ------------------------------------------------------------------------------
// Legacy

Expand Down
17 changes: 14 additions & 3 deletions src/app/util/af-main-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,21 @@ EmberStatus emAfSend(EmberOutgoingMessageType type, uint64_t indexOrDestination,
EmberStatus status = EMBER_SUCCESS;
switch (type)
{
case EMBER_OUTGOING_VIA_BINDING:
// No implementation yet.
status = EMBER_ERR_FATAL;
case EMBER_OUTGOING_VIA_BINDING: {
EmberBindingTableEntry binding;
status = emberGetBinding(indexOrDestination, &binding);
if (status != EMBER_SUCCESS)
{
break;
}
if (binding.type != EMBER_UNICAST_BINDING)
{
status = EMBER_INVALID_BINDING_INDEX;
break;
}
status = chipSendUnicast(binding.nodeId, apsFrame, messageLength, message);
break;
}
case EMBER_OUTGOING_VIA_ADDRESS_TABLE:
// No implementation yet.
status = EMBER_ERR_FATAL;
Expand Down
16 changes: 8 additions & 8 deletions src/app/util/client-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ uint16_t emberAfFillBuffer(uint8_t * buffer, uint16_t bufferLen, uint8_t frameCo
return returnValue;
}

// EmberStatus emberAfSendCommandUnicastToBindingsWithCallback(EmberAfMessageSentFunction callback)
// {
// return emberAfSendUnicastToBindingsWithCallback(emAfCommandApsFrame, *emAfResponseLengthPtr, emAfZclBuffer, callback);
// }
EmberStatus emberAfSendCommandUnicastToBindingsWithCallback(EmberAfMessageSentFunction callback)
{
return emberAfSendUnicastToBindingsWithCallback(emAfCommandApsFrame, *emAfResponseLengthPtr, emAfZclBuffer, callback);
}

// EmberStatus emberAfSendCommandUnicastToBindings(void)
// {
// return emberAfSendCommandUnicastToBindingsWithCallback(NULL);
// }
EmberStatus emberAfSendCommandUnicastToBindings(void)
{
return emberAfSendCommandUnicastToBindingsWithCallback(NULL);
}

// EmberStatus emberAfSendCommandMulticastWithCallback(EmberMulticastId multicastId, EmberAfMessageSentFunction callback)
// {
Expand Down

0 comments on commit 2302752

Please sign in to comment.