use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspSendUnicastRequest in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleEzsp method sendCommand.
@Override
public void sendCommand(final ZigBeeApsFrame apsFrame) {
if (ashHandler == null) {
return;
}
EzspFrameRequest emberCommand;
EmberApsFrame emberApsFrame = new EmberApsFrame();
emberApsFrame.setClusterId(apsFrame.getCluster());
emberApsFrame.setProfileId(apsFrame.getProfile());
emberApsFrame.setSourceEndpoint(apsFrame.getSourceEndpoint());
emberApsFrame.setDestinationEndpoint(apsFrame.getDestinationEndpoint());
emberApsFrame.setSequence(apsFrame.getApsCounter());
emberApsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_RETRY);
emberApsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_ENABLE_ROUTE_DISCOVERY);
emberApsFrame.addOptions(EmberApsOption.EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY);
if (apsFrame.getAddressMode() == ZigBeeNwkAddressMode.DEVICE && apsFrame.getDestinationAddress() < 0xfff8) {
EzspSendUnicastRequest emberUnicast = new EzspSendUnicastRequest();
emberUnicast.setIndexOrDestination(apsFrame.getDestinationAddress());
emberUnicast.setMessageTag(apsFrame.getSequence());
emberUnicast.setSequenceNumber(apsFrame.getSequence());
emberUnicast.setType(EmberOutgoingMessageType.EMBER_OUTGOING_DIRECT);
emberUnicast.setApsFrame(emberApsFrame);
emberUnicast.setMessageContents(apsFrame.getPayload());
emberCommand = emberUnicast;
} else if (apsFrame.getAddressMode() == ZigBeeNwkAddressMode.DEVICE && apsFrame.getDestinationAddress() >= 0xfff8) {
EzspSendBroadcastRequest emberBroadcast = new EzspSendBroadcastRequest();
emberBroadcast.setDestination(apsFrame.getDestinationAddress());
emberBroadcast.setMessageTag(apsFrame.getSequence());
emberBroadcast.setSequenceNumber(apsFrame.getSequence());
emberBroadcast.setApsFrame(emberApsFrame);
emberBroadcast.setRadius(apsFrame.getRadius());
emberBroadcast.setMessageContents(apsFrame.getPayload());
emberCommand = emberBroadcast;
} else if (apsFrame.getAddressMode() == ZigBeeNwkAddressMode.GROUP) {
emberApsFrame.setGroupId(apsFrame.getGroupAddress());
EzspSendMulticastRequest emberMulticast = new EzspSendMulticastRequest();
emberMulticast.setApsFrame(emberApsFrame);
emberMulticast.setHops(apsFrame.getRadius());
emberMulticast.setNonmemberRadius(apsFrame.getNonMemberRadius());
emberMulticast.setMessageTag(apsFrame.getSequence());
emberMulticast.setMessageContents(apsFrame.getPayload());
emberCommand = emberMulticast;
} else {
logger.debug("EZSP message not sent: {}, {}", apsFrame);
// apsFrame.setGroupId(groupAddress.getGroupId());
return;
}
logger.debug(emberCommand.toString());
ashHandler.queueFrame(emberCommand);
// emberUnicast = (EzspSendUnicast) ashHandler.sendEzspRequestAsync(emberUnicast);
}
Aggregations