A. If you created a class named BYourDriverDeviceDiscoverRequest in the previous chapters of the day's lesson:
Create a class named BYourDriverDeviceDiscoveryResponse that extends BDdfResponse and implements BIDdfDiscoverResponse. Create this class in the package com.yourCompany.yourDriver.comm.rsp.
package com.yourCompany.yourDriver.comm.rsp; import com.tridium.ddf.comm.rsp.*; import javax.baja.sys.*; public class BYourDriverDeviceDiscoverResponse extends BDdfResponse implements BIDdfDiscoverResponse { /*- class BYourDriverDeviceDiscoverResponse { } -*/ }
B. If you decided to have your driver's ping request and device id also serve as the discover request/discover parameters:
Update the class declaration for BYourDriverPingResponse and declare it so that it implements BIDdfDiscoverResponse. Also add a statement to import com.tridium.ddf.discover.*.
package com.yourCompany.yourDriver.comm.rsp; import com.tridium.ddf.comm.*; import com.tridium.ddf.discover.*; import javax.baja.sys.*; public class BYourDriverPingResponse extends BDdfResponse implements BIDdfDiscoverResponse { ... }
/** * This method parses the response byte array and returns an * array of BYourDriverDeviceId objects describing the devices * that this response is able to identify. This is called during * the auto discovery process. */ public BIDdfDiscoveryObject[] parseDiscoveryObjects(Context c) { return null; }
/** * In our hypothetical protocol, we know that by receiving any * response to the ping request than the deviceId of the transaction * represents a device that is online. */ public BIDdfDiscoveryObject[] parseDiscoveryObjects(Context c) { // Returns an array of size one, containing just the deviceId // Of the response. Please note that for drivers that are not // Re-using the ping request as a discovery request, then this // Method should parse through the response bytes and make an // Array of BYourDriverDeviceId whose length corresponds to // The number of device entries that you determine are present // In the response bytes. Then assign each BYourDriverDeviceId // Entry in the array based on what you are able to parse from // The response bytes. return new BIDdfDiscoveryObject[]{ (BIDdfDiscoveryObject)getDeviceId().newCopy() }; }
Copyright © 2000-2014 Tridium Inc. All rights reserved.