Skip to content

Commit fe69355

Browse files
committed
Implementing example SimpleZigBeeConsole using SimpleZigBeeApi. Implemented management LQI request and response.
1 parent 016054c commit fe69355

3 files changed

Lines changed: 232 additions & 0 deletions

File tree

zigbee-api/src/main/java/org/bubblecloud/zigbee/network/zdo/ZdoCommandTransmitter.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ public void sendCommand(final ZdoCommand command) throws ZigBeeException {
172172
getZToolAddress16(userDescriptorRequest.getDestinationAddress()),
173173
getZToolAddress16(userDescriptorRequest.getNetworkAddressOfInterest())));
174174
}
175+
if (command instanceof ManagementLqiRequest) {
176+
final ManagementLqiRequest managementLqiRequest = (ManagementLqiRequest) command;
177+
networkManager.sendCommand(new ZDO_MGMT_LQI_REQ(
178+
getZToolAddress16(managementLqiRequest.getNetworkAddress()),
179+
managementLqiRequest.getStartIndex()
180+
));
181+
}
175182
}
176183
}
177184

@@ -358,6 +365,35 @@ public void receivedAsynchronousCommand(ZToolPacket packet) {
358365
notifyCommandReceived(command);
359366
return;
360367
}
368+
369+
if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_MGMT_LQI_RSP) {
370+
final ZDO_MGMT_LQI_RSP message = (ZDO_MGMT_LQI_RSP) packet;
371+
372+
final ZDO_MGMT_LQI_RSP.NeighborLqiListItemClass[] neighborItems = message.getNeighborLqiList();
373+
final ManagementLqiResponse.Neighbor[] neighbors = new ManagementLqiResponse.Neighbor[neighborItems.length];
374+
for (int i = 0; i < neighbors.length; i++) {
375+
neighbors[i] = new ManagementLqiResponse.Neighbor(
376+
neighborItems[i].Depth,
377+
neighborItems[i].ExtendedPanID,
378+
neighborItems[i].ExtendedAddress.getLong(),
379+
neighborItems[i].NetworkAddress.get16BitValue(),
380+
neighborItems[i].Reserved_Relationship_RxOnWhenIdle_DeviceType,
381+
neighborItems[i].Reserved_PermitJoining,
382+
neighborItems[i].RxLQI);
383+
}
384+
385+
final ManagementLqiResponse command = new ManagementLqiResponse(
386+
message.Status,
387+
message.SrcAddress.get16BitValue(),
388+
message.getStartIndex(),
389+
message.getNeighborLQICount(),
390+
neighbors
391+
);
392+
393+
notifyCommandReceived(command);
394+
395+
return;
396+
}
361397
}
362398

363399
@Override
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.bubblecloud.zigbee.network.zdo.command;
2+
3+
import org.bubblecloud.zigbee.network.zdo.ZdoCommand;
4+
import org.bubblecloud.zigbee.simple.ZdoRequest;
5+
6+
/**
7+
* ManagementLqiRequest.
8+
*/
9+
public class ManagementLqiRequest extends ZdoCommand implements ZdoRequest {
10+
/**
11+
* The network address.
12+
*/
13+
private int networkAddress;
14+
/**
15+
* The started index.
16+
*/
17+
private int startIndex;
18+
19+
public ManagementLqiRequest() {
20+
}
21+
22+
public ManagementLqiRequest(int networkAddress, int type, int startIndex) {
23+
this.networkAddress = networkAddress;
24+
this.startIndex = startIndex;
25+
}
26+
27+
public int getNetworkAddress() {
28+
return networkAddress;
29+
}
30+
31+
public void setNetworkAddress(int networkAddress) {
32+
this.networkAddress = networkAddress;
33+
}
34+
35+
public int getStartIndex() {
36+
return startIndex;
37+
}
38+
39+
public void setStartIndex(int startIndex) {
40+
this.startIndex = startIndex;
41+
}
42+
43+
@Override
44+
public String toString() {
45+
return "Management LQI Request " +
46+
"networkAddress=" + networkAddress +
47+
", startIndex=" + startIndex;
48+
}
49+
50+
@Override
51+
public int getDestinationAddress() {
52+
return networkAddress;
53+
}
54+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package org.bubblecloud.zigbee.network.zdo.command;
2+
3+
import org.bubblecloud.zigbee.network.zdo.ZdoCommand;
4+
import org.bubblecloud.zigbee.simple.ZdoResponse;
5+
6+
import java.util.Arrays;
7+
8+
/**
9+
* ManagementLqiResponse.
10+
*/
11+
public class ManagementLqiResponse extends ZdoCommand implements ZdoResponse {
12+
/**
13+
* The status.
14+
*/
15+
private int status;
16+
/**
17+
* Network address.
18+
*/
19+
private int sourceAddress;
20+
/**
21+
* Start index.
22+
*/
23+
public int startIndex;
24+
/**
25+
* Number of neighbors.
26+
*/
27+
public int numberOfNeighbors;
28+
/**
29+
* Neighbors.
30+
*/
31+
public Neighbor[] neighbors;
32+
33+
public ManagementLqiResponse() {
34+
}
35+
36+
public ManagementLqiResponse(int status, int sourceAddress, int startIndex, int numberOfNeighbors, Neighbor[] associatedDeviceList) {
37+
this.status = status;
38+
this.sourceAddress = sourceAddress;
39+
this.startIndex = startIndex;
40+
this.numberOfNeighbors = numberOfNeighbors;
41+
this.neighbors = associatedDeviceList;
42+
}
43+
44+
@Override
45+
public int getStatus() {
46+
return status;
47+
}
48+
49+
public void setStatus(int status) {
50+
this.status = status;
51+
}
52+
53+
public int getSourceAddress() {
54+
return sourceAddress;
55+
}
56+
57+
public void setSourceAddress(int sourceAddress) {
58+
this.sourceAddress = sourceAddress;
59+
}
60+
61+
public int getStartIndex() {
62+
return startIndex;
63+
}
64+
65+
public void setStartIndex(int startIndex) {
66+
this.startIndex = startIndex;
67+
}
68+
69+
public int getNumberOfNeighbors() {
70+
return numberOfNeighbors;
71+
}
72+
73+
public void setNumberOfNeighbors(int numberOfNeighbors) {
74+
this.numberOfNeighbors = numberOfNeighbors;
75+
}
76+
77+
public Neighbor[] getNeighbors() {
78+
return neighbors;
79+
}
80+
81+
public void setNeighbors(Neighbor[] neighbors) {
82+
this.neighbors = neighbors;
83+
}
84+
85+
@Override
86+
public String toString() {
87+
return "Management LQI Response " +
88+
"status=" + status +
89+
", sourceAddress=" + sourceAddress +
90+
", startIndex=" + startIndex +
91+
", numberOfNeighbors=" + numberOfNeighbors +
92+
", neighbors=" + Arrays.toString(neighbors);
93+
}
94+
95+
public static class Neighbor {
96+
public int depth;
97+
public long extendedPanId;
98+
public long ieeeAddress;
99+
public int networkAddress;
100+
public int relationshipRxOnWhenIdleDeviceType;
101+
public int permitJoining;
102+
public int lqi;
103+
104+
public Neighbor(int depth, long extendedPanId, long ieeeAddress, int networkAddress, int relationshipRxOnWhenIdleDeviceType, int permitJoining, int lqi) {
105+
this.depth = depth;
106+
this.extendedPanId = extendedPanId;
107+
this.ieeeAddress = ieeeAddress;
108+
this.networkAddress = networkAddress;
109+
this.relationshipRxOnWhenIdleDeviceType = relationshipRxOnWhenIdleDeviceType;
110+
this.permitJoining = permitJoining;
111+
this.lqi = lqi;
112+
}
113+
114+
public int getDepth() {
115+
return depth;
116+
}
117+
118+
public long getExtendedPanId() {
119+
return extendedPanId;
120+
}
121+
122+
public long getIeeeAddress() {
123+
return ieeeAddress;
124+
}
125+
126+
public int getNetworkAddress() {
127+
return networkAddress;
128+
}
129+
130+
public int getRelationshipRxOnWhenIdleDeviceType() {
131+
return relationshipRxOnWhenIdleDeviceType;
132+
}
133+
134+
public int getPermitJoining() {
135+
return permitJoining;
136+
}
137+
138+
public int getLqi() {
139+
return lqi;
140+
}
141+
}
142+
}

0 commit comments

Comments
 (0)