Skip to content

Commit

Permalink
Add GetRadioParameters methods (zsmartsystems#1407)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson authored and charbopassman committed Jul 26, 2024
1 parent 16cce4a commit 6e0018d
Show file tree
Hide file tree
Showing 11 changed files with 513 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import com.zsmartsystems.zigbee.ZigBeeNetworkManager;
import com.zsmartsystems.zigbee.dongle.ember.EmberNcp;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspGetNetworkParametersResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspGetRadioParametersResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspVersionResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberMultiPhyRadioParameters;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberNetworkParameters;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberNetworkStatus;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberStatus;
Expand Down Expand Up @@ -90,6 +92,8 @@ private void ncpState(ZigBeeNetworkManager networkManager, PrintStream out) {
int nwkAddress = ncp.getNwkAddress();
EzspGetNetworkParametersResponse nwkParameterResponse = ncp.getNetworkParameters();
EmberNetworkParameters nwkParameters = nwkParameterResponse.getParameters();
EzspGetRadioParametersResponse radioParametersResponse = ncp.getRadioParameters();
EmberMultiPhyRadioParameters radioParameters = radioParametersResponse.getParameters();

String mfgName = ncp.getMfgName();
String mfgBoard = ncp.getMfgBoardName();
Expand All @@ -104,9 +108,11 @@ private void ncpState(ZigBeeNetworkManager networkManager, PrintStream out) {
out.println("NWK Address : " + String.format("%04X", nwkAddress));
out.println("Network PAN Id : " + String.format("%04X", nwkParameters.getPanId()));
out.println("Network EPAN Id : " + nwkParameters.getExtendedPanId());
out.println("Radio Channel : " + nwkParameters.getRadioChannel());
out.println(
"Radio Channel : " + radioParameters.getRadioChannel() + " / " + nwkParameters.getRadioChannel());
out.println("Network Manager Id : " + String.format("%04X", nwkParameters.getNwkManagerId()));
out.println("Radio TX Power : " + nwkParameters.getRadioTxPower());
out.println(
"Radio TX Power : " + radioParameters.getRadioTxPower() + " / " + nwkParameters.getRadioTxPower());
out.println("Join Method : " + nwkParameters.getJoinMethod());
out.println("Board Name : " + mfgBoard);
out.println("Manufacturer Name : " + mfgName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public static void main(final String[] args) {
}
}

transportOptions.addOption(TransportConfigOption.RADIO_TX_POWER, 8);
transportOptions.addOption(TransportConfigOption.RADIO_TX_POWER, 20);

// Configure the concentrator
// Max Hops defaults to system max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ protected String getTypeClass(String dataType) {
case "EmberBeaconIterator":
case "EmberMulticastTableEntry":
case "EmberKeyStatus":
case "EmberMultiPhyRadioParameters":
addImport(ezspStructurePackage + "." + dataTypeLocal);
return dataTypeLocal + modifier;
default:
Expand Down Expand Up @@ -897,6 +898,7 @@ protected String getTypeSerializer(String dataType) {
case "EmberBeaconData":
case "EmberBeaconIterator":
case "EmberMulticastTableEntry":
case "EmberMultiPhyRadioParameters":
return dataTypeLocal;
default:
return dataType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3699,6 +3699,31 @@
</response_parameters>
</command>

<command>
<name>getRadioParameters</name>
<id>0xFD</id>
<description>Returns the current radio parameters based on phy index.</description>
<command_parameters>
<parameter>
<data_type>uint8_t</data_type>
<name>childCount</name>
<description>The number of children the node currently has.</description>
</parameter>
</command_parameters>
<response_parameters>
<parameter>
<data_type>EmberStatus</data_type>
<name>status</name>
<description>The result of the CBKE operation.</description>
</parameter>
<parameter>
<data_type>EmberMultiPhyRadioParameters</data_type>
<name>parameters</name>
<description>The current radio parameters.</description>
</parameter>
</response_parameters>
</command>

<command>
<name>requestLinkKey</name>
<id>0x14</id>
Expand Down Expand Up @@ -4469,6 +4494,28 @@
</parameters>
</structure>

<structure>
<name>EmberMultiPhyRadioParameters</name>
<description>Radio parameters.</description>
<parameters>
<parameter>
<data_type>uint8_t</data_type>
<name>radioTxPower</name>
<description>A power setting, in dBm.</description>
</parameter>
<parameter>
<data_type>uint8_t</data_type>
<name>radioPage</name>
<description>A radio page.</description>
</parameter>
<parameter>
<data_type>uint8_t</data_type>
<name>radioChannel</name>
<description>A radio channel.</description>
</parameter>
</parameters>
</structure>

<structure>
<name>EmberGpAddress</name>
<description>A GP address structure.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ public EzspGetNetworkParametersResponse getNetworkParameters() {
return (EzspGetNetworkParametersResponse) transaction.getResponse();
}

/**
* Gets the current radio parameters, or an empty parameters class if there's an error
*
* @return {@link EzspGetRadioParametersResponse} or null on error
*/
public EzspGetRadioParametersResponse getRadioParameters() {
EzspGetRadioParametersRequest request = new EzspGetRadioParametersRequest();
request.setChildCount(1);
EzspTransaction transaction = zigBeeDongleEzsp.getProtocolHandler().sendEzspTransaction(
new EzspSingleResponseTransaction(request, EzspGetRadioParametersResponse.class));
return (EzspGetRadioParametersResponse) transaction.getResponse();
}

/**
* Returns a value indicating whether the node is joining, joined to, or leaving a network.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public abstract class EzspFrame {
protected static final int FRAME_ID_GET_NUM_STORED_BEACONS = 0x08;
protected static final int FRAME_ID_GET_PARENT_CHILD_PARAMETERS = 0x29;
protected static final int FRAME_ID_GET_POLICY = 0x56;
protected static final int FRAME_ID_GET_RADIO_PARAMETERS = 0xFD;
protected static final int FRAME_ID_GET_ROUTE_TABLE_ENTRY = 0x7B;
protected static final int FRAME_ID_GET_ROUTING_SHORTCUT_THRESHOLD = 0xD1;
protected static final int FRAME_ID_GET_SOURCE_ROUTE_TABLE_ENTRY = 0xC1;
Expand Down Expand Up @@ -304,6 +305,7 @@ public abstract class EzspFrame {
ezspHandlerMap.put(FRAME_ID_GET_NUM_STORED_BEACONS, EzspGetNumStoredBeaconsResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_PARENT_CHILD_PARAMETERS, EzspGetParentChildParametersResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_POLICY, EzspGetPolicyResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_RADIO_PARAMETERS, EzspGetRadioParametersResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_ROUTE_TABLE_ENTRY, EzspGetRouteTableEntryResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_ROUTING_SHORTCUT_THRESHOLD, EzspGetRoutingShortcutThresholdResponse.class);
ezspHandlerMap.put(FRAME_ID_GET_SOURCE_ROUTE_TABLE_ENTRY, EzspGetSourceRouteTableEntryResponse.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* Copyright (c) 2016-2023 by the respective copyright holders.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.zsmartsystems.zigbee.dongle.ember.ezsp.command;

import com.zsmartsystems.zigbee.dongle.ember.ezsp.EzspFrameRequest;
import com.zsmartsystems.zigbee.dongle.ember.internal.serializer.EzspSerializer;

/**
* Class to implement the Ember EZSP command <b>getRadioParameters</b>.
* <p>
* Returns the current radio parameters based on phy index.
* <p>
* This class provides methods for processing EZSP commands.
* <p>
* Note that this code is autogenerated. Manual changes may be overwritten.
*
* @author Chris Jackson - Initial contribution of Java code generator
*/
public class EzspGetRadioParametersRequest extends EzspFrameRequest {
public static final int FRAME_ID = 0xFD;

/**
* The number of children the node currently has.
* <p>
* EZSP type is <i>uint8_t</i> - Java type is {@link int}
*/
private int childCount;

/**
* Serialiser used to serialise to binary line data
*/
private EzspSerializer serializer;

/**
* Request constructor
*/
public EzspGetRadioParametersRequest() {
frameId = FRAME_ID;
serializer = new EzspSerializer();
}

/**
* The number of children the node currently has.
* <p>
* EZSP type is <i>uint8_t</i> - Java type is {@link int}
*
* @return the current childCount as {@link int}
*/
public int getChildCount() {
return childCount;
}

/**
* The number of children the node currently has.
*
* @param childCount the childCount to set as {@link int}
*/
public void setChildCount(int childCount) {
this.childCount = childCount;
}

@Override
public int[] serialize() {
// Serialize the header
serializeHeader(serializer);

// Serialize the fields
serializer.serializeUInt8(childCount);
return serializer.getPayload();
}

@Override
public String toString() {
final StringBuilder builder = new StringBuilder(82);
builder.append("EzspGetRadioParametersRequest [networkId=");
builder.append(networkId);
builder.append(", childCount=");
builder.append(childCount);
builder.append(']');
return builder.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Copyright (c) 2016-2023 by the respective copyright holders.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.zsmartsystems.zigbee.dongle.ember.ezsp.command;

import com.zsmartsystems.zigbee.dongle.ember.ezsp.EzspFrameResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberMultiPhyRadioParameters;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberStatus;

/**
* Class to implement the Ember EZSP command <b>getRadioParameters</b>.
* <p>
* Returns the current radio parameters based on phy index.
* <p>
* This class provides methods for processing EZSP commands.
* <p>
* Note that this code is autogenerated. Manual changes may be overwritten.
*
* @author Chris Jackson - Initial contribution of Java code generator
*/
public class EzspGetRadioParametersResponse extends EzspFrameResponse {
public static final int FRAME_ID = 0xFD;

/**
* The result of the CBKE operation.
* <p>
* EZSP type is <i>EmberStatus</i> - Java type is {@link EmberStatus}
*/
private EmberStatus status;

/**
* The current radio parameters.
* <p>
* EZSP type is <i>EmberMultiPhyRadioParameters</i> - Java type is {@link EmberMultiPhyRadioParameters}
*/
private EmberMultiPhyRadioParameters parameters;

/**
* Response and Handler constructor
*/
public EzspGetRadioParametersResponse(int[] inputBuffer) {
// Super creates deserializer and reads header fields
super(inputBuffer);

// Deserialize the fields
status = deserializer.deserializeEmberStatus();
parameters = deserializer.deserializeEmberMultiPhyRadioParameters();
}

/**
* The result of the CBKE operation.
* <p>
* EZSP type is <i>EmberStatus</i> - Java type is {@link EmberStatus}
*
* @return the current status as {@link EmberStatus}
*/
public EmberStatus getStatus() {
return status;
}

/**
* The result of the CBKE operation.
*
* @param status the status to set as {@link EmberStatus}
*/
public void setStatus(EmberStatus status) {
this.status = status;
}

/**
* The current radio parameters.
* <p>
* EZSP type is <i>EmberMultiPhyRadioParameters</i> - Java type is {@link EmberMultiPhyRadioParameters}
*
* @return the current parameters as {@link EmberMultiPhyRadioParameters}
*/
public EmberMultiPhyRadioParameters getParameters() {
return parameters;
}

/**
* The current radio parameters.
*
* @param parameters the parameters to set as {@link EmberMultiPhyRadioParameters}
*/
public void setParameters(EmberMultiPhyRadioParameters parameters) {
this.parameters = parameters;
}

@Override
public String toString() {
final StringBuilder builder = new StringBuilder(108);
builder.append("EzspGetRadioParametersResponse [networkId=");
builder.append(networkId);
builder.append(", status=");
builder.append(status);
builder.append(", parameters=");
builder.append(parameters);
builder.append(']');
return builder.toString();
}
}
Loading

0 comments on commit 6e0018d

Please sign in to comment.