Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Ember support for simplicity_sdk:2024.12.0 #1275

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Ember support for simplicity_sdk:2024.12.0
Nerivec committed Dec 27, 2024
commit f729f0355fb57820587847df6cb628c076ee862a
2 changes: 2 additions & 0 deletions src/adapter/ember/consts.ts
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ export const APS_ENCRYPTION_OVERHEAD = 9;
/** The additional overhead required for APS fragmentation. */
export const APS_FRAGMENTATION_OVERHEAD = 2;

/** An inactive concentrator. */
export const EMBER_INACTIVE_CONCENTRATOR = 0xffff;
/**
* A concentrator with insufficient memory to store source routes for the entire network.
* Route records are sent to the concentrator prior to every inbound APS unicast.
4 changes: 3 additions & 1 deletion src/adapter/ember/enums.ts
Original file line number Diff line number Diff line change
@@ -1344,8 +1344,10 @@ export enum EmberCounterType {
PTA_HI_PRI_TX_ABORTED = 39,
/** The number of times an address conflict has caused node_id change, and an address conflict error is sent. */
ADDRESS_CONFLICT_SENT = 40,
/** The number of times CSL failed to schedule Rx on target */
CSL_RX_SCHEDULE_FAILED = 41,
/** A placeholder giving the number of Ember counter types. */
COUNT = 41,
COUNT = 42,
}

/* eslint-disable @typescript-eslint/no-duplicate-enum-values */
21 changes: 21 additions & 0 deletions src/adapter/ember/ezsp/buffalo.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import Buffalo from '../../../buffalo/buffalo';
import {GP_SINK_LIST_ENTRIES} from '../consts';
import {EmberGpApplicationId, EmberGpSinkType, EzspStatus, SLStatus} from '../enums';
import {
Ember802154RadioPriorities,
EmberAesMmoHashContext,
EmberApsFrame,
EmberBeaconClassificationParams,
@@ -1336,6 +1337,7 @@ export class EzspBuffalo extends Buffalo {
};
}

/** @deprecated removed in EZSP v16 in favor of @see readEmber802154RadioPriorities */
public readEmberMultiprotocolPriorities(): EmberMultiprotocolPriorities {
const backgroundRx = this.readUInt8();
const tx = this.readUInt8();
@@ -1344,12 +1346,31 @@ export class EzspBuffalo extends Buffalo {
return {backgroundRx, tx, activeRx};
}

/** @deprecated removed in EZSP v16 in favor of @see writeEmber802154RadioPriorities */
public writeEmberMultiprotocolPriorities(priorities: EmberMultiprotocolPriorities): void {
this.writeUInt8(priorities.backgroundRx);
this.writeUInt8(priorities.tx);
this.writeUInt8(priorities.activeRx);
}

public readEmber802154RadioPriorities(): Ember802154RadioPriorities {
const backgroundRx = this.readUInt8();
const minTxPriority = this.readUInt8();
const txStep = this.readUInt8();
const maxTxPriority = this.readUInt8();
const activeRx = this.readUInt8();

return {backgroundRx, minTxPriority, txStep, maxTxPriority, activeRx};
}

public writeEmber802154RadioPriorities(priorities: Ember802154RadioPriorities): void {
this.writeUInt8(priorities.backgroundRx);
this.writeUInt8(priorities.minTxPriority);
this.writeUInt8(priorities.txStep);
this.writeUInt8(priorities.maxTxPriority);
this.writeUInt8(priorities.activeRx);
}

public readEmberRxPacketInfo(): EmberRxPacketInfo {
const senderShortId = this.readUInt16();
const senderLongId = this.readIeeeAddr();
4 changes: 2 additions & 2 deletions src/adapter/ember/ezsp/consts.ts
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@

export const EZSP_MIN_PROTOCOL_VERSION = 0x0d;
/** Latest EZSP protocol version */
export const EZSP_PROTOCOL_VERSION = 0x0e;
export const EZSP_PROTOCOL_VERSION = 0x10;

/** EZSP max length + Frame Control extra byte + Frame ID extra byte */
export const EZSP_MAX_FRAME_LENGTH = 200 + 1 + 1;
export const EZSP_MAX_FRAME_LENGTH = 218 + 1 + 1;

/** EZSP Sequence Index for both legacy and extended frame format */
export const EZSP_SEQUENCE_INDEX = 0;
34 changes: 29 additions & 5 deletions src/adapter/ember/ezsp/ezsp.ts
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ import {
} from '../enums';
import {EzspError} from '../ezspError';
import {
Ember802154RadioPriorities,
EmberAesMmoHashContext,
EmberApsFrame,
EmberBeaconClassificationParams,
@@ -1059,6 +1060,22 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
const mic = this.callbackBuffalo.readUInt32();
const proxyTableIndex = this.callbackBuffalo.readUInt8();
const gpdCommandPayload = this.callbackBuffalo.readPayload();
let packetInfo: EmberRxPacketInfo;

if (this.version < 0x10) {
packetInfo = {
senderShortId: ZSpec.NULL_NODE_ID,
senderLongId: ZSpec.BLANK_EUI64,
bindingIndex: ZSpec.NULL_BINDING,
addressIndex: 0xff,
lastHopLqi: gpdLink,
lastHopRssi: 0,
lastHopTimestamp: 0,
};
} else {
packetInfo = this.callbackBuffalo.readEmberRxPacketInfo();
}

this.ezspGpepIncomingMessageHandler(
gpStatus,
gpdLink,
@@ -1073,6 +1090,7 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
mic,
proxyTableIndex,
gpdCommandPayload,
packetInfo,
);
break;
}
@@ -2482,7 +2500,7 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
* Get the current scheduler priorities for multiprotocol apps.
* @returns The current priorities.
*/
async ezspRadioGetSchedulerPriorities(): Promise<EmberMultiprotocolPriorities> {
async ezspRadioGetSchedulerPriorities(): Promise<Ember802154RadioPriorities | EmberMultiprotocolPriorities> {
if (this.version < 0x0e) {
throw new EzspError(EzspStatus.ERROR_INVALID_FRAME_ID);
}
@@ -2495,7 +2513,7 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
throw new EzspError(sendStatus);
}

const priorities = this.buffalo.readEmberMultiprotocolPriorities();
const priorities = this.version < 0x10 ? this.buffalo.readEmberMultiprotocolPriorities() : this.buffalo.readEmber802154RadioPriorities();

return priorities;
}
@@ -2504,13 +2522,18 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
* Set the current scheduler priorities for multiprotocol apps.
* @param priorities The current priorities.
*/
async ezspRadioSetSchedulerPriorities(priorities: EmberMultiprotocolPriorities): Promise<void> {
async ezspRadioSetSchedulerPriorities(priorities: Ember802154RadioPriorities | EmberMultiprotocolPriorities): Promise<void> {
if (this.version < 0x0e) {
throw new EzspError(EzspStatus.ERROR_INVALID_FRAME_ID);
}

const sendBuffalo = this.startCommand(EzspFrameID.RADIO_SET_SCHEDULER_PRIORITIES);
sendBuffalo.writeEmberMultiprotocolPriorities(priorities);

if (this.version < 0x10) {
sendBuffalo.writeEmberMultiprotocolPriorities(priorities as EmberMultiprotocolPriorities);
} else {
sendBuffalo.writeEmber802154RadioPriorities(priorities as Ember802154RadioPriorities);
}

const sendStatus = await this.sendCommand(sendBuffalo);

@@ -8564,14 +8587,15 @@ export class Ezsp extends EventEmitter<EmberEzspEventMap> {
mic: number,
proxyTableIndex: number,
gpdCommandPayload: Buffer,
packetInfo: EmberRxPacketInfo,
): void {
logger.debug(
() =>
`ezspGpepIncomingMessageHandler(): callback called with: [status=${EmberGPStatus[status] ?? status}], [gpdLink=${gpdLink}], ` +
`[sequenceNumber=${sequenceNumber}], [addr=${JSON.stringify(addr)}], [gpdfSecurityLevel=${EmberGpSecurityLevel[gpdfSecurityLevel]}], ` +
`[gpdfSecurityKeyType=${EmberGpKeyType[gpdfSecurityKeyType]}], [autoCommissioning=${autoCommissioning}], ` +
`[bidirectionalInfo=${bidirectionalInfo}], [gpdSecurityFrameCounter=${gpdSecurityFrameCounter}], [gpdCommandId=${gpdCommandId}], ` +
`[mic=${mic}], [proxyTableIndex=${proxyTableIndex}], [gpdCommandPayload=${gpdCommandPayload.toString('hex')}]`,
`[mic=${mic}], [proxyTableIndex=${proxyTableIndex}], [gpdCommandPayload=${gpdCommandPayload.toString('hex')}], [packetInfo=${JSON.stringify(packetInfo)}]`,
NS,
);

15 changes: 15 additions & 0 deletions src/adapter/ember/types.ts
Original file line number Diff line number Diff line change
@@ -807,6 +807,7 @@ export type EmberEndpointDescription = {
outputClusterCount: number;
};

/** @deprecated removed in EZSP v16 in favor of @see Ember802154RadioPriorities */
export type EmberMultiprotocolPriorities = {
/** The priority of a Zigbee RX operation while not receiving a packet. uint8_t */
backgroundRx: number;
@@ -816,6 +817,20 @@ export type EmberMultiprotocolPriorities = {
activeRx: number;
};

/** Struct used to specify priorities for Zigbee radio operations */
export type Ember802154RadioPriorities = {
/** The priority of a Zigbee RX operation while not receiving a packet. uint8_t */
backgroundRx: number;
/** Starting priority of a Zigbee TX operation. The first transmit of the packet, before retries, uses this priority. uint8_t */
minTxPriority: number;
/** The increase in TX priority (which is a decrement in value) for each retry. uint8_t */
txStep: number;
/** Maximum priority of a Zigbee TX operation. Retried messages have priorities bumped by tx_step, up to a maximum of max_tx_priority. uint8_t */
maxTxPriority: number;
/** The priority of a Zigbee RX operation while receiving a packet. uint8_t */
activeRx: number;
};

/** @brief Received packet information.
*
* Contains information about the incoming packet.