zigbee-herdsman
Version:
An open source ZigBee gateway solution with node.js.
904 lines • 172 kB
TypeScript
import EventEmitter from "node:events";
import type { Eui64, ExtendedPanId, NodeId, PanId } from "../../../zspec/tstypes";
import * as Zdo from "../../../zspec/zdo";
import type { SerialPortOptions } from "../../tstype";
import { EmberCounterType, EmberDeviceUpdate, type EmberDutyCycleState, type EmberEntropySource, type EmberEventUnits, type EmberExtendedSecurityBitmask, EmberGPStatus, EmberGpKeyType, EmberGpSecurityLevel, EmberIncomingMessageType, EmberJoinDecision, EmberKeyStatus, EmberLeaveNetworkOption, type EmberLibraryId, type EmberLibraryStatus, type EmberMacPassthroughType, type EmberMultiPhyNwkConfig, type EmberNetworkStatus, type EmberNodeType, EmberOutgoingMessageType, type EmberSourceRouteDiscoveryMode, EmberStackError, type EmberTXPowerMode, type EmberTransmitPriority, type EzspNetworkScanType, EzspStatus, type EzspZllNetworkOperation, type IEEE802154CcaMode, SLStatus, SecManFlag } from "../enums";
import type { Ember802154RadioPriorities, EmberAesMmoHashContext, EmberApsFrame, EmberBeaconClassificationParams, EmberBeaconData, EmberBindingTableEntry, EmberCertificate283k1Data, EmberCertificateData, EmberChildData, EmberCurrentSecurityState, EmberDutyCycleLimits, EmberEndpointDescription, EmberGpAddress, EmberGpProxyTableEntry, EmberGpSinkTableEntry, EmberInitialSecurityState, EmberKeyData, EmberMessageDigest, EmberMultiPhyRadioParameters, EmberMulticastTableEntry, EmberMultiprotocolPriorities, EmberNeighborTableEntry, EmberNetworkInitStruct, EmberNetworkParameters, EmberPerDeviceDutyCycle, EmberPrivateKeyData, EmberPublicKey283k1Data, EmberPublicKeyData, EmberRouteTableEntry, EmberRxPacketInfo, EmberSignature283k1Data, EmberSignatureData, EmberSmacData, EmberTokTypeStackZllData, EmberTokTypeStackZllSecurity, EmberTokenData, EmberTokenInfo, EmberVersion, EmberZigbeeNetwork, EmberZllAddressAssignment, EmberZllDeviceInfoRecord, EmberZllInitialSecurityState, EmberZllNetwork, SecManAPSKeyMetadata, SecManContext, SecManKey, SecManNetworkKeyInfo } from "../types";
import { UartAsh } from "../uart/ash";
import { EzspBuffalo } from "./buffalo";
import { type EmberLeaveReason, type EmberRejoinReason, type EzspConfigId, type EzspEndpointFlag, EzspExtendedValueId, EzspMfgTokenId, type EzspPolicyId, EzspValueId } from "./enums";
export interface EmberEzspEventMap {
/** An error was detected that requires resetting the NCP. */
ncpNeedsResetAndInit: [status: EzspStatus];
/** @see Ezsp.ezspIncomingMessageHandler */
zdoResponse: [apsFrame: EmberApsFrame, sender: NodeId, messageContents: Buffer];
/** ezspIncomingMessageHandler */
incomingMessage: [type: EmberIncomingMessageType, apsFrame: EmberApsFrame, lastHopLqi: number, sender: NodeId, messageContents: Buffer];
/** @see Ezsp.ezspMacFilterMatchMessageHandler */
touchlinkMessage: [sourcePanId: PanId, sourceAddress: Eui64, groupId: number, lastHopLqi: number, messageContents: Buffer];
/** @see Ezsp.ezspStackStatusHandler */
stackStatus: [status: SLStatus];
/** @see Ezsp.ezspTrustCenterJoinHandler */
trustCenterJoin: [
newNodeId: NodeId,
newNodeEui64: Eui64,
status: EmberDeviceUpdate,
policyDecision: EmberJoinDecision,
parentOfNewNodeId: NodeId
];
/** @see Ezsp.ezspMessageSentHandler */
messageSent: [status: SLStatus, type: EmberOutgoingMessageType, indexOrDestination: number, apsFrame: EmberApsFrame, messageTag: number];
}
/**
* Host EZSP layer.
*
* Provides functions that allow the Host application to send every EZSP command to the NCP.
*
* Commands to send to the serial>ASH layers all are named `ezsp${CommandName}`.
* They do nothing but build the command, send it and return the value(s).
* Callers are expected to handle errors appropriately.
* - They will throw `EzspStatus` if `sendCommand` fails or the returned value(s) by NCP are invalid (wrong length, etc).
* - Most will return `EmberStatus` given by NCP (some `EzspStatus`, some `SLStatus`...).
*/
export declare class Ezsp extends EventEmitter<EmberEzspEventMap> {
private version;
readonly ash: UartAsh;
private readonly buffalo;
/** The contents of the current EZSP frame. CAREFUL using this guy, it's pre-allocated. */
private readonly frameContents;
/** The total Length of the incoming frame */
private frameLength;
private readonly callbackBuffalo;
/** The contents of the current EZSP frame. CAREFUL using this guy, it's pre-allocated. */
private readonly callbackFrameContents;
/** The total Length of the incoming frame */
private callbackFrameLength;
private initialVersionSent;
/** EZSP frame sequence number. Used in EZSP_SEQUENCE_INDEX byte. */
private frameSequence;
/** Sequence used for EZSP send() tagging. static uint8_t */
private sendSequence;
private readonly queue;
/** Awaiting response resolve/timer struct. undefined if not waiting for response. */
private responseWaiter?;
/** Counter for Queue Full errors */
counterErrQueueFull: number;
constructor(options: SerialPortOptions);
/**
* Returns the number of EZSP responses that have been received by the serial
* protocol and are ready to be collected by the EZSP layer via
* responseReceived().
*/
get pendingResponseCount(): number;
/**
* Create a string representation of the last received frame in storage.
*/
get frameToString(): string;
/**
* Create a string representation of the last received callback frame in storage.
*/
get callbackFrameToString(): string;
start(): Promise<EzspStatus>;
/**
* Cleanly close down the serial protocol (UART).
* After this function has been called, init() must be called to resume communication with the NCP.
*/
stop(): Promise<void>;
/**
* Must be called immediately after `ezspVersion` to sync the Host protocol version.
* @param version Version for the Host to use.
*/
setProtocolVersion(version: number): void;
/**
* Check if connected.
* If not, attempt to restore the connection.
*
* @returns
*/
checkConnection(): boolean;
/**
* Triggered by @see 'FATAL_ERROR'
*/
private onAshFatalError;
/**
* Triggered by @see 'FRAME'
*/
private onAshFrame;
/**
* Event from the EZSP layer indicating that the transaction with the NCP could not be completed due to a
* serial protocol error or that the response received from the NCP reported an error.
* The status parameter provides more information about the error.
*
* @param status
*/
ezspErrorHandler(status: EzspStatus): void;
private nextFrameSequence;
private startCommand;
/**
* Sends the current EZSP command frame. Returns EZSP_SUCCESS if the command was sent successfully.
* Any other return value means that an error has been detected by the serial protocol layer.
*
* if ezsp.sendCommand fails early, this will be:
* - EzspStatus.ERROR_INVALID_CALL
* - EzspStatus.NOT_CONNECTED
* - EzspStatus.ERROR_COMMAND_TOO_LONG
*
* if ezsp.sendCommand fails, this will be whatever ash.send returns:
* - EzspStatus.SUCCESS
* - EzspStatus.NO_TX_SPACE
* - EzspStatus.DATA_FRAME_TOO_SHORT
* - EzspStatus.DATA_FRAME_TOO_LONG
* - EzspStatus.NOT_CONNECTED
*
* if ezsp.sendCommand times out, this will be EzspStatus.ASH_ERROR_TIMEOUTS
*
* if ezsp.sendCommand resolves, this will be whatever ezsp.responseReceived returns:
* - EzspStatus.NO_RX_DATA (should not happen if command was sent (since we subscribe to frame event to trigger function))
* - status from EzspFrameID.INVALID_COMMAND status byte
* - EzspStatus.ERROR_UNSUPPORTED_CONTROL
* - EzspStatus.ERROR_WRONG_DIRECTION
* - EzspStatus.ERROR_TRUNCATED
* - EzspStatus.SUCCESS
*/
private sendCommand;
/**
* Sets the stage for parsing if valid (indexes buffalo to params index).
* @returns
*/
validateReceivedFrame(buffalo: EzspBuffalo): EzspStatus;
/**
* Dispatches callback frames handlers.
*/
callbackDispatch(): void;
/**
*
* @returns uint8_t
*/
private nextSendSequence;
/**
* Calls ezspSend${x} based on type and takes care of tagging message.
*
* Alias types expect `alias` & `sequence` params, along with `apsFrame.radius`.
*
* @param type Specifies the outgoing message type.
* @param indexOrDestination uint16_t Depending on the type of addressing used, this is either the NodeId of the destination,
* an index into the address table, or an index into the binding table.
* Unused for multicast types.
* This must be one of the three ZigBee broadcast addresses for broadcast.
* @param apsFrame [IN/OUT] EmberApsFrame * The APS frame which is to be added to the message.
* Sequence set in OUT as returned by ezspSend${x} command
* @param message uint8_t * Content of the message.
* @param alias The alias source address
* @param sequence uint8_t The alias sequence number
* @returns Result of the ezspSend${x} call or EmberStatus.INVALID_PARAMETER if type not supported.
* @returns messageTag Tag used for ezspSend${x} command
*/
send(type: EmberOutgoingMessageType, indexOrDestination: number, apsFrame: EmberApsFrame, message: Buffer, alias: NodeId, sequence: number): Promise<[SLStatus, messageTag: number]>;
/**
* Retrieving the new version info.
* Wrapper for `ezspGetValue`.
* @returns Send status
* @returns EmberVersion*, null if status not SUCCESS.
*/
ezspGetVersionStruct(): Promise<[SLStatus, version: EmberVersion]>;
/**
* Function for manipulating the endpoints flags on the NCP.
* Wrapper for `ezspGetExtendedValue`
* @param endpoint uint8_t
* @param flags EzspEndpointFlags
* @returns EzspStatus
*/
ezspSetEndpointFlags(endpoint: number, flags: EzspEndpointFlag): Promise<SLStatus>;
/**
* Function for manipulating the endpoints flags on the NCP.
* Wrapper for `ezspGetExtendedValue`.
* @param endpoint uint8_t
* @returns EzspStatus
* @returns flags
*/
ezspGetEndpointFlags(endpoint: number): Promise<[SLStatus, flags: EzspEndpointFlag]>;
/**
* Wrapper for `ezspGetExtendedValue`.
* @param NodeId
* @param destination
* @returns EzspStatus
* @returns overhead uint8_t
*/
ezspGetSourceRouteOverhead(destination: NodeId): Promise<[SLStatus, overhead: number]>;
/**
* Wrapper for `ezspGetExtendedValue`.
* @returns EzspStatus
* @returns reason
* @returns nodeId NodeId*
*/
ezspGetLastLeaveReason(): Promise<[SLStatus, reason: EmberLeaveReason, nodeId: NodeId]>;
/**
* Wrapper for `ezspGetValue`.
* @returns EzspStatus
* @returns reason
*/
ezspGetLastRejoinReason(): Promise<[SLStatus, reason: EmberRejoinReason]>;
/**
* Wrapper for `ezspSetValue`.
* @param mask
* @returns
*/
ezspSetExtendedSecurityBitmask(mask: EmberExtendedSecurityBitmask): Promise<SLStatus>;
/**
* Wrapper for `ezspGetValue`.
* @returns
*/
ezspGetExtendedSecurityBitmask(): Promise<[SLStatus, mask: EmberExtendedSecurityBitmask]>;
/**
* Wrapper for `ezspSetValue`.
* @returns
*/
ezspStartWritingStackTokens(): Promise<SLStatus>;
/**
* Wrapper for `ezspSetValue`.
* @returns
*/
ezspStopWritingStackTokens(): Promise<SLStatus>;
/**
* Wrapper for `ezspSetValue`.
*
* Set NWK layer outgoing frame counter (intended for device restoration purposes).
* Caveats:
* - Can only be called before NetworkInit / FormNetwork / JoinNetwork, when sl_zigbee_network_state()==SL_ZIGBEE_NO_NETWORK.
* - This function should be called before ::sl_zigbee_set_initial_security_state, and the SL_ZIGBEE_NO_FRAME_COUNTER_RESET
* bitmask should be added to the initial security bitmask when ::emberSetInitialSecurityState is called.
* - If used in multi-network context, be sure to call ::sl_zigbee_set_current_network() prior to calling this function.
*
* @param desiredValue The desired outgoing NWK frame counter value.
* This should needs to be less than MAX_INT32U_VALUE to ensure that rollover does not occur on the next encrypted transmission.
* @returns
* - SL_STATUS_OK if calling context is valid (sl_zigbee_network_state() == SL_ZIGBEE_NO_NETWORK) and desiredValue < MAX_INT32U_VALUE.
* - SL_STATUS_INVALID_STATE.
*/
ezspSetNWKFrameCounter(frameCounter: number): Promise<SLStatus>;
/**
* Wrapper for `ezspSetValue`.
*
* Function to set APS layer outgoing frame counter for Trust Center Link Key (intended for device restoration purposes).
* Caveats:
* - Can only be called before NetworkInit / FormNetwork / JoinNetwork, when sl_zigbee_network_state()==SL_ZIGBEE_NO_NETWORK.
* - This function should be called before ::sl_zigbee_set_initial_security_state, and the SL_ZIGBEE_NO_FRAME_COUNTER_RESET
* bitmask should be added to the initial security bitmask when ::emberSetInitialSecurityState is called.
* - If used in multi-network context, be sure to call ::sl_zigbee_set_current_network() prior to calling this function.
*
* @param desiredValue The desired outgoing APS frame counter value.
* This should needs to be less than MAX_INT32U_VALUE to ensure that rollover does not occur on the next encrypted transmission.
* @returns
* - SL_STATUS_OK if calling context is valid (sl_zigbee_network_state() == SL_ZIGBEE_NO_NETWORK) and desiredValue < MAX_INT32U_VALUE.
* - SL_STATUS_INVALID_STATE.
*/
ezspSetAPSFrameCounter(frameCounter: number): Promise<SLStatus>;
/**
* The command allows the Host to specify the desired EZSP version and must be
* sent before any other command. The response provides information about the
* firmware running on the NCP.
*
* @param desiredProtocolVersion uint8_t The EZSP version the Host wishes to use.
* To successfully set the version and allow other commands, this must be same as EZSP_PROTOCOL_VERSION.
* @returns uint8_t The EZSP version the NCP is using.
* @returns uint8_t * The type of stack running on the NCP (2).
* @returns uint16_t * The version number of the stack.
*/
ezspVersion(desiredProtocolVersion: number): Promise<[protocolVersion: number, stackType: number, stackVersion: number]>;
/**
* Reads a configuration value from the NCP.
*
* @param configId Identifies which configuration value to read.
* @returns
* - SLStatus.OK if the value was read successfully,
* - SLStatus.ZIGBEE_EZSP_ERROR (for SL_ZIGBEE_EZSP_ERROR_INVALID_ID) if the NCP does not recognize configId.
* @returns uint16_t * The configuration value.
*/
ezspGetConfigurationValue(configId: EzspConfigId): Promise<[SLStatus, value: number]>;
/**
* Writes a configuration value to the NCP. Configuration values can be modified
* by the Host after the NCP has reset. Once the status of the stack changes to
* EMBER_NETWORK_UP, configuration values can no longer be modified and this
* command will respond with EzspStatus.ERROR_INVALID_CALL.
*
* @param configId Identifies which configuration value to change.
* @param value uint16_t The new configuration value.
* @returns EzspStatus
* - SLStatus.OK if the configuration value was changed,
* - SLStatus.ZIGBEE_EZSP_ERROR if the new value exceeded the available memory,
* if the new value was out of bounds,
* if the NCP does not recognize configId,
* if configuration values can no longer be modified.
*/
ezspSetConfigurationValue(configId: EzspConfigId, value: number): Promise<SLStatus>;
/**
* Read attribute data on NCP endpoints.
* @param endpoint uint8_t Endpoint
* @param cluster uint16_t Cluster.
* @param attributeId uint16_t Attribute ID.
* @param mask uint8_t Mask.
* @param manufacturerCode uint16_t Manufacturer code.
* @returns An sl_zigbee_af_status_t value indicating success or the reason for failure, handled by the EZSP layer as a uint8_t.
* @returns uint8_t * Attribute data type.
* @returns uint8_t * Length of attribute data.
* @returns uint8_t * Attribute data.
*/
ezspReadAttribute(endpoint: number, cluster: number, attributeId: number, mask: number, manufacturerCode: number, readLength: number): Promise<[SLStatus, dataType: number, outReadLength: number, data: number[]]>;
/**
* Write attribute data on NCP endpoints.
* @param endpoint uint8_t Endpoint
* @param cluster uint16_t Cluster.
* @param attributeId uint16_t Attribute ID.
* @param mask uint8_t Mask.
* @param manufacturerCode uint16_t Manufacturer code.
* @param overrideReadOnlyAndDataType Override read only and data type.
* @param justTest Override read only and data type.
* @param dataType uint8_t Attribute data type.
* @param data uint8_t * Attribute data.
* @returns An sl_zigbee_af_status_t value indicating success or the reason for failure.
*/
ezspWriteAttribute(endpoint: number, cluster: number, attributeId: number, mask: number, manufacturerCode: number, overrideReadOnlyAndDataType: boolean, justTest: boolean, dataType: number, data: Buffer): Promise<SLStatus>;
/**
* Configures endpoint information on the NCP. The NCP does not remember these
* settings after a reset. Endpoints can be added by the Host after the NCP has
* reset. Once the status of the stack changes to EMBER_NETWORK_UP, endpoints
* can no longer be added and this command will respond with EzspStatus.ERROR_INVALID_CALL.
* @param endpoint uint8_t The application endpoint to be added.
* @param profileId uint16_t The endpoint's application profile.
* @param deviceId uint16_t The endpoint's device ID within the application profile.
* @param deviceVersion uint8_t The endpoint's device version.
* @param inputClusterList uint16_t * Input cluster IDs the endpoint will accept.
* @param outputClusterList uint16_t * Output cluster IDs the endpoint may send.
* @returns
* - SLStatus.OK if the endpoint was added,
* - SLStatus.ZIGBEE_EZSP_ERROR if there is not enough memory available to add the endpoint,
* if the endpoint already exists,
* if endpoints can no longer be added.
*/
ezspAddEndpoint(endpoint: number, profileId: number, deviceId: number, deviceVersion: number, inputClusterList: number[], outputClusterList: number[]): Promise<SLStatus>;
/**
* Allows the Host to change the policies used by the NCP to make fast
* decisions.
* @param policyId Identifies which policy to modify.
* @param decisionId The new decision for the specified policy.
* @returns
* - SLStatus.OK if the policy was changed,
* - SLStatus.ZIGBEE_EZSP_ERROR if the NCP does not recognize policyId.
*/
ezspSetPolicy(policyId: EzspPolicyId, decisionId: number): Promise<SLStatus>;
/**
* Allows the Host to read the policies used by the NCP to make fast decisions.
* @param policyId Identifies which policy to read.
* @returns
* - SLStatus.OK if the policy was read successfully,
* - SLStatus.ZIGBEE_EZSP_ERROR if the NCP does not recognize policyId.
* @returns EzspDecisionId * The current decision for the specified policy.
*/
ezspGetPolicy(policyId: EzspPolicyId): Promise<[SLStatus, number]>;
/**
* Triggers a pan id update message.
* @param The new Pan Id
* @returns true if the request was successfully handed to the stack, false otherwise
*/
ezspSendPanIdUpdate(newPan: PanId): Promise<boolean>;
/**
* Reads a value from the NCP.
* @param valueId Identifies which value to read.
* @returns
* - SLStatus.OK if the value was read successfully,
* - SLStatus.ZIGBEE_EZSP_ERROR if the NCP does not recognize valueId,
* if the length of the returned value exceeds the size of local storage allocated to receive it.
* @returns uint8_t * Both a command and response parameter.
* On command, the maximum in bytes of local storage allocated to receive the returned value.
* On response, the actual length in bytes of the returned value.
* @returns uint8_t * The value.
*/
ezspGetValue(valueId: EzspValueId, valueLength: number): Promise<[SLStatus, outValueLength: number, outValue: number[]]>;
/**
* Reads a value from the NCP but passes an extra argument specific to the value
* being retrieved.
* @param valueId Identifies which extended value ID to read.
* @param characteristics uint32_t Identifies which characteristics of the extended value ID to read. These are specific to the value being read.
* @returns
* - SLStatus.OK if the value was read successfully,
* - SLStatus.ZIGBEE_EZSP_ERROR if the NCP does not recognize valueId,
* if the length of the returned value exceeds the size of local storage allocated to receive it.
* @returns uint8_t * Both a command and response parameter.
* On command, the maximum in bytes of local storage allocated to receive the returned value.
* On response, the actual length in bytes of the returned value.
* @returns uint8_t * The value.
*/
ezspGetExtendedValue(valueId: EzspExtendedValueId, characteristics: number, valueLength: number): Promise<[SLStatus, outValueLength: number, outValue: number[]]>;
/**
* Writes a value to the NCP.
* @param valueId Identifies which value to change.
* @param valueLength uint8_t The length of the value parameter in bytes.
* @param value uint8_t * The new value.
* @returns
* - SLStatus.OK if the value was changed,
* - SLStatus.ZIGBEE_EZSP_ERROR if the new value was out of bounds,
* if the NCP does not recognize valueId,
* if the value could not be modified.
*/
ezspSetValue(valueId: EzspValueId, valueLength: number, value: number[]): Promise<SLStatus>;
/**
* Allows the Host to control the broadcast behaviour of a routing device used by the NCP.
* @param config uint8_t Passive ack config enum.
* @param minAcksNeeded uint8_t The minimum number of acknowledgments (re-broadcasts) to wait for until
* deeming the broadcast transmission complete.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspSetPassiveAckConfig(config: number, minAcksNeeded: number): Promise<SLStatus>;
/**
* Set the PAN ID to be accepted by the device in a NLME Network Update command.
* If this is set to a different value than its default 0xFFFF, NLME network update messages will be ignored if they do not match this PAN ID.
* @param panId uint16_t PAN ID to be accepted in a network update.
*/
ezspSetPendingNetworkUpdatePanId(panId: PanId): Promise<void>;
/**
* Retrieve the endpoint number located at the specified index.
* @param index uint8_t Index to retrieve the endpoint number for.
* @returns uint8_t Endpoint number at the index.
*/
ezspGetEndpoint(index: number): Promise<number>;
/**
* Get the number of configured endpoints.
* @returns uint8_t Number of configured endpoints.
*/
ezspGetEndpointCount(): Promise<number>;
/**
* Retrieve the endpoint description for the given endpoint number.
* @param endpoint Endpoint number to get the description of.
* @returns Description of this endpoint.
*/
ezspGetEndpointDescription(endpoint: number): Promise<EmberEndpointDescription>;
/**
* Retrieve one of the cluster IDs associated with the given endpoint.
* @param endpoint Endpoint number to get a cluster ID for.
* @param listId Which list to get the cluster ID from. (0 for input, 1 for output).
* @param listIndex Index from requested list to look at the cluster ID of.
* @returns ID of the requested cluster.
*/
ezspGetEndpointCluster(endpoint: number, listId: number, listIndex: number): Promise<number>;
/**
* A command which does nothing. The Host can use this to set the sleep mode or to check the status of the NCP.
*/
ezspNop(): Promise<void>;
/**
* Variable length data from the Host is echoed back by the NCP.
* This command has no other effects and is designed for testing the link between the Host and NCP.
* @param data uint8_t * The data to be echoed back.
* @returns uint8_t * The echo of the data.
*/
ezspEcho(data: Buffer): Promise<Buffer>;
/**
* Allows the NCP to respond with a pending callback.
*/
ezspCallback(): Promise<void>;
/**
* Callback
* Indicates that there are currently no pending callbacks.
*/
ezspNoCallbacks(): void;
/**
* Sets a token (8 bytes of non-volatile storage) in the Simulated EEPROM of the NCP.
* @param tokenId uint8_t Which token to set
* @param tokenData uint8_t * The data to write to the token.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspSetToken(tokenId: number, tokenData: number[]): Promise<SLStatus>;
/**
* Retrieves a token (8 bytes of non-volatile storage) from the Simulated EEPROM of the NCP.
* @param tokenId uint8_t Which token to read
* @returns An SLStatus value indicating success or the reason for failure.
* @returns uint8_t * The contents of the token.
*/
ezspGetToken(tokenId: number): Promise<[SLStatus, tokenData: number[]]>;
/**
* Retrieves a manufacturing token from the Flash Information Area of the NCP
* (except for EZSP_STACK_CAL_DATA which is managed by the stack).
* @param tokenId Which manufacturing token to read.
* @returns uint8_t The length of the tokenData parameter in bytes.
* @returns uint8_t * The manufacturing token data.
*/
ezspGetMfgToken(tokenId: EzspMfgTokenId): Promise<[number, tokenData: number[]]>;
/**
* Sets a manufacturing token in the Customer Information Block (CIB) area of
* the NCP if that token currently unset (fully erased). Cannot be used with
* EZSP_STACK_CAL_DATA, EZSP_STACK_CAL_FILTER, EZSP_MFG_ASH_CONFIG, or
* EZSP_MFG_CBKE_DATA token.
* @param tokenId Which manufacturing token to set.
* @param tokenData uint8_t * The manufacturing token data.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspSetMfgToken(tokenId: EzspMfgTokenId, tokenData: Buffer): Promise<SLStatus>;
/**
* Callback
* A callback invoked to inform the application that a stack token has changed.
* @param tokenAddress uint16_t The address of the stack token that has changed.
*/
ezspStackTokenChangedHandler(tokenAddress: number): void;
/**
* Returns a pseudorandom number.
* @returns Always returns SLStatus.OK.
* @returns uint16_t * A pseudorandom number.
*/
ezspGetRandomNumber(): Promise<[SLStatus, value: number]>;
/**
* Sets a timer on the NCP. There are 2 independent timers available for use by the Host.
* A timer can be cancelled by setting time to 0 or units to EMBER_EVENT_INACTIVE.
* @param timerId uint8_t Which timer to set (0 or 1).
* @param time uint16_t The delay before the timerHandler callback will be generated.
* Note that the timer clock is free running and is not synchronized with this command.
* This means that the actual delay will be between time and (time - 1). The maximum delay is 32767.
* @param units The units for time.
* @param repeat If true, a timerHandler callback will be generated repeatedly. If false, only a single timerHandler callback will be generated.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspSetTimer(timerId: number, time: number, units: EmberEventUnits, repeat: boolean): Promise<SLStatus>;
/**
* Gets information about a timer. The Host can use this command to find out how
* much longer it will be before a previously set timer will generate a
* callback.
* @param timerId uint8_t Which timer to get information about (0 or 1).
* @returns uint16_t The delay before the timerHandler callback will be generated.
* @returns EmberEventUnits * The units for time.
* @returns bool * True if a timerHandler callback will be generated repeatedly. False if only a single timerHandler callback will be generated.
*/
ezspGetTimer(timerId: number): Promise<[number, units: EmberEventUnits, repeat: boolean]>;
/**
* Callback
* A callback from the timer.
* @param timerId uint8_t Which timer generated the callback (0 or 1).
*/
ezspTimerHandler(timerId: number): void;
/**
* Sends a debug message from the Host to the Network Analyzer utility via the NCP.
* @param binaryMessage true if the message should be interpreted as binary data, false if the message should be interpreted as ASCII text.
* @param messageContents uint8_t * The binary message.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspDebugWrite(binaryMessage: boolean, messageContents: Buffer): Promise<SLStatus>;
/**
* Retrieves and clears Ember counters. See the EmberCounterType enumeration for the counter types.
* @returns uint16_t * A list of all counter values ordered according to the EmberCounterType enumeration.
*/
ezspReadAndClearCounters(): Promise<number[]>;
/**
* Retrieves Ember counters. See the EmberCounterType enumeration for the counter types.
* @returns uint16_t * A list of all counter values ordered according to the EmberCounterType enumeration.
*/
ezspReadCounters(): Promise<number[]>;
/**
* Callback
* This call is fired when a counter exceeds its threshold
* @param type Type of Counter
*/
ezspCounterRolloverHandler(type: EmberCounterType): void;
/**
* Used to test that UART flow control is working correctly.
* @param delay uint16_t Data will not be read from the host for this many milliseconds.
*/
ezspDelayTest(delay: number): Promise<void>;
/**
* This retrieves the status of the passed library ID to determine if it is compiled into the stack.
* @param libraryId The ID of the library being queried.
* @returns The status of the library being queried.
*/
ezspGetLibraryStatus(libraryId: EmberLibraryId): Promise<EmberLibraryStatus>;
/**
* Allows the HOST to know whether the NCP is running the XNCP library. If so,
* the response contains also the manufacturer ID and the version number of the
* XNCP application that is running on the NCP.
* @returns
* - SLStatus.OK if the NCP is running the XNCP library.
* - SLStatus.INVALID_STATE otherwise.
* @returns manufacturerId uint16_t * The manufactured ID the user has defined in the XNCP application.
* @returns versionNumber uint16_t * The version number of the XNCP application.
*/
ezspGetXncpInfo(): Promise<[SLStatus, manufacturerId: number, versionNumber: number]>;
/**
* Provides the customer a custom EZSP frame. On the NCP, these frames are only
* handled if the XNCP library is included. On the NCP side these frames are
* handled in the emberXNcpIncomingCustomEzspMessageCallback() callback
* function.
* @param uint8_t * The payload of the custom frame (maximum 119 bytes).
* @param uint8_t The expected length of the response.
* @returns The status returned by the custom command.
* @returns uint8_t *The response.
*/
ezspCustomFrame(payload: Buffer, replyLength: number): Promise<[SLStatus, outReply: Buffer]>;
/**
* Callback
* A callback indicating a custom EZSP message has been received.
* @param payload uint8_t * The payload of the custom frame.
*/
ezspCustomFrameHandler(payload: Buffer): void;
/**
* Returns the EUI64 ID of the local node.
* @returns The 64-bit ID.
*/
ezspGetEui64(): Promise<Eui64>;
/**
* Returns the 16-bit node ID of the local node.
* @returns The 16-bit ID.
*/
ezspGetNodeId(): Promise<NodeId>;
/**
* Returns number of phy interfaces present.
* @returns uint8_t Value indicate how many phy interfaces present.
*/
ezspGetPhyInterfaceCount(): Promise<number>;
/**
* Returns the entropy source used for true random number generation.
* @returns Value indicates the used entropy source.
*/
ezspGetTrueRandomEntropySource(): Promise<EmberEntropySource>;
/**
* Extend a joiner's timeout to wait for the network key on the joiner default key timeout is 3 sec,
* and only values greater equal to 3 sec are accepted.
* @param networkKeyTimeoutS Network key timeout
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspSetupDelayedJoin(networkKeyTimeoutS: number): Promise<SLStatus>;
/**
* Get the current scheduler priorities for multiprotocol apps.
* @returns The current priorities.
*/
ezspRadioGetSchedulerPriorities(): Promise<Ember802154RadioPriorities | EmberMultiprotocolPriorities>;
/**
* Set the current scheduler priorities for multiprotocol apps.
* @param priorities The current priorities.
*/
ezspRadioSetSchedulerPriorities(priorities: Ember802154RadioPriorities | EmberMultiprotocolPriorities): Promise<void>;
/**
* Get the current multiprotocol sliptime
* @returns Value of the current slip time.
*/
ezspRadioGetSchedulerSliptime(): Promise<number>;
/**
* Set the current multiprotocol sliptime
* @param slipTime Value of the current slip time.
*/
ezspRadioSetSchedulerSliptime(slipTime: number): Promise<void>;
/**
* Check if a particular counter is one that could report from either a 2.4GHz or sub-GHz interface.
* @param counter The counter to be checked.
* @returns Whether this counter requires a PHY index when operating on a dual-PHY system.
*/
ezspCounterRequiresPhyIndex(counter: EmberCounterType): Promise<boolean>;
/**
* Check if a particular counter can report on the destination node ID they have been triggered from.
* @param counter The counter to be checked.
* @returns Whether this counter requires the destination node ID.
*/
ezspCounterRequiresDestinationNodeId(counter: EmberCounterType): Promise<boolean>;
/**
* Sets the manufacturer code to the specified value.
* The manufacturer code is one of the fields of the node descriptor.
* @param code uint16_t The manufacturer code for the local node.
*/
ezspSetManufacturerCode(code: number): Promise<void>;
/**
* Gets the manufacturer code to the specified value.
* The manufacturer code is one of the fields of the node descriptor.
* @returns The manufacturer code for the local node.
*/
ezspGetManufacturerCode(): Promise<number>;
/**
* Sets the power descriptor to the specified value. The power descriptor is a
* dynamic value. Therefore, you should call this function whenever the value
* changes.
* @param descriptor uint16_t The new power descriptor for the local node.
* @returns An SLStatus value indicating success or the reason for failure. Always `OK` in v13-.
*/
ezspSetPowerDescriptor(descriptor: number): Promise<SLStatus>;
/**
* Resume network operation after a reboot. The node retains its original type.
* This should be called on startup whether or not the node was previously part
* of a network. EMBER_NOT_JOINED is returned if the node is not part of a
* network. This command accepts options to control the network initialization.
* @param networkInitStruct EmberNetworkInitStruct * An EmberNetworkInitStruct containing the options for initialization.
* @returns
* - SLStatus.OK if successful initialization,
* - SLStatus.NOT_JOINED if the node is not part of a network
* - or the reason for failure.
*/
ezspNetworkInit(networkInitStruct: EmberNetworkInitStruct): Promise<SLStatus>;
/**
* Returns a value indicating whether the node is joining, joined to, or leaving a network.
* @returns Command send status.
* @returns An EmberNetworkStatus value indicating the current join status.
*/
ezspNetworkState(): Promise<EmberNetworkStatus>;
/**
* Callback
* A callback invoked when the status of the stack changes. If the status
* parameter equals EMBER_NETWORK_UP, then the getNetworkParameters command can
* be called to obtain the new network parameters. If any of the parameters are
* being stored in nonvolatile memory by the Host, the stored values should be
* updated.
* @param status Stack status
*/
ezspStackStatusHandler(status: SLStatus): void;
/**
* This function will start a scan.
* @param scanType Indicates the type of scan to be performed. Possible values are: EZSP_ENERGY_SCAN and EZSP_ACTIVE_SCAN.
* For each type, the respective callback for reporting results is: energyScanResultHandler and networkFoundHandler.
* The energy scan and active scan report errors and completion via the scanCompleteHandler.
* @param channelMask uint32_t Bits set as 1 indicate that this particular channel should be scanned.
* Bits set to 0 indicate that this particular channel should not be scanned. For example, a channelMask value of 0x00000001
* would indicate that only channel 0 should be scanned. Valid channels range from 11 to 26 inclusive.
* This translates to a channel mask value of 0x07FFF800.
* As a convenience, a value of 0 is reinterpreted as the mask for the current channel.
* @param duration uint8_t Sets the exponent of the number of scan periods, where a scan period is 960 symbols.
* The scan will occur for ((2^duration) + 1) scan periods.
* @returns
* - SLStatus.OK signals that the scan successfully started. Possible error responses and their meanings:
* - SLStatus.MAC_SCANNING, we are already scanning;
* - SLStatus.BAD_SCAN_DURATION, we have set a duration value that is not 0..14 inclusive;
* - SLStatus.MAC_INCORRECT_SCAN_TYPE, we have requested an undefined scanning type;
* - SLStatus.INVALID_CHANNEL_MASK, our channel mask did not specify any valid channels.
*/
ezspStartScan(scanType: EzspNetworkScanType, channelMask: number, duration: number): Promise<SLStatus>;
/**
* Callback
* Reports the result of an energy scan for a single channel. The scan is not
* complete until the scanCompleteHandler callback is called.
* @param channel uint8_t The 802.15.4 channel number that was scanned.
* @param maxRssiValue int8_t The maximum RSSI value found on the channel.
*/
ezspEnergyScanResultHandler(channel: number, maxRssiValue: number): void;
/**
* Callback
* Reports that a network was found as a result of a prior call to startScan.
* Gives the network parameters useful for deciding which network to join.
* @param networkFound EmberZigbeeNetwork * The parameters associated with the network found.
* @param lastHopLqi uint8_t The link quality from the node that generated this beacon.
* @param lastHopRssi int8_t The energy level (in units of dBm) observed during the reception.
*/
ezspNetworkFoundHandler(networkFound: EmberZigbeeNetwork, lastHopLqi: number, lastHopRssi: number): void;
/**
* Callback
* @param channel uint8_t The channel on which the current error occurred. Undefined for the case of EMBER_SUCCESS.
* @param status The error condition that occurred on the current channel. Value will be SLStatus.OK when the scan has completed.
* Other error conditions signify a failure to scan on the channel specified.
*/
ezspScanCompleteHandler(channel: number, status: SLStatus): void;
/**
* Callback
* This function returns an unused panID and channel pair found via the find
* unused panId scan procedure.
* @param panId The unused panID which has been found.
* @param channel uint8_t The channel that the unused panID was found on.
*/
ezspUnusedPanIdFoundHandler(panId: PanId, channel: number): void;
/**
* This function starts a series of scans which will return an available panId.
* @param channelMask uint32_t The channels that will be scanned for available panIds.
* @param duration uint8_t The duration of the procedure.
* @returns The error condition that occurred during the scan. Value will be SLStatus.OK if there are no errors.
*/
ezspFindUnusedPanId(channelMask: number, duration: number): Promise<SLStatus>;
/**
* Terminates a scan in progress.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspStopScan(): Promise<SLStatus>;
/**
* Forms a new network by becoming the coordinator.
* @param parameters EmberNetworkParameters * Specification of the new network.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspFormNetwork(parameters: EmberNetworkParameters): Promise<SLStatus>;
/**
* Causes the stack to associate with the network using the specified network
* parameters. It can take several seconds for the stack to associate with the
* local network. Do not send messages until the stackStatusHandler callback
* informs you that the stack is up.
* @param nodeType Specification of the role that this node will have in the network.
* This role must not be EMBER_COORDINATOR. To be a coordinator, use the formNetwork command.
* @param parameters EmberNetworkParameters * Specification of the network with which the node should associate.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspJoinNetwork(nodeType: EmberNodeType, parameters: EmberNetworkParameters): Promise<SLStatus>;
/**
* Causes the stack to associate with the network using the specified network
* parameters in the beacon parameter. It can take several seconds for the stack
* to associate with the local network. Do not send messages until the
* stackStatusHandler callback informs you that the stack is up. Unlike
* ::emberJoinNetwork(), this function does not issue an active scan before
* joining. Instead, it will cause the local node to issue a MAC Association
* Request directly to the specified target node. It is assumed that the beacon
* parameter is an artifact after issuing an active scan. (For more information,
* see emberGetBestBeacon and emberGetNextBeacon.)
* @param localNodeType Specifies the role that this node will have in the network. This role must not be EMBER_COORDINATOR.
* To be a coordinator, use the formNetwork command.
* @param beacon EmberBeaconData * Specifies the network with which the node should associate.
* @param radioTxPower int8_t The radio transmit power to use, specified in dBm.
* @param clearBeaconsAfterNetworkUp If true, clear beacons in cache upon join success. If join fail, do nothing.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspJoinNetworkDirectly(localNodeType: EmberNodeType, beacon: EmberBeaconData, radioTxPower: number, clearBeaconsAfterNetworkUp: boolean): Promise<SLStatus>;
/**
* Causes the stack to leave the current network. This generates a
* stackStatusHandler callback to indicate that the network is down. The radio
* will not be used until after sending a formNetwork or joinNetwork command.
* @param options This parameter gives options when leave network
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspLeaveNetwork(options?: EmberLeaveNetworkOption): Promise<SLStatus>;
/**
* The application may call this function when contact with the network has been
* lost. The most common usage case is when an end device can no longer
* communicate with its parent and wishes to find a new one. Another case is
* when a device has missed a Network Key update and no longer has the current
* Network Key. The stack will call ezspStackStatusHandler to indicate that the
* network is down, then try to re-establish contact with the network by
* performing an active scan, choosing a network with matching extended pan id,
* and sending a ZigBee network rejoin request. A second call to the
* ezspStackStatusHandler callback indicates either the success or the failure
* of the attempt. The process takes approximately 150 milliseconds per channel
* to complete.
* @param haveCurrentNetworkKey This parameter tells the stack whether to try to use the current network key.
* If it has the current network key it will perform a secure rejoin (encrypted). If this fails the device should try an unsecure rejoin.
* If the Trust Center allows the rejoin then the current Network Key will be sent encrypted using the device's Link Key.
* @param channelMask uint32_t A mask indicating the channels to be scanned. See emberStartScan for format details.
* A value of 0 is reinterpreted as the mask for the current channel.
* @param reason uint8_t A sl_zigbee_rejoin_reason_t variable which could be passed in if there is actually a reason for rejoin,
* or could be left at 0xFF
* @param nodeType uint8_t The rejoin could be triggered with a different nodeType.
* This value could be set to 0 or SL_ZIGBEE_DEVICE_TYPE_UNCHANGED if not needed.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspFindAndRejoinNetwork(haveCurrentNetworkKey: boolean, channelMask: number, reason?: number, nodeType?: number): Promise<SLStatus>;
/**
* Tells the stack to allow other nodes to join the network with this node as
* their parent. Joining is initially disabled by default.
* @param duration uint8_t A value of 0x00 disables joining. A value of 0xFF enables joining.
* Any other value enables joining for that number of seconds.
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspPermitJoining(duration: number): Promise<SLStatus>;
/**
* Callback
* Indicates that a child has joined or left.
* @param index uint8_t The index of the child of interest.
* @param joining True if the child is joining. False the child is leaving.
* @param childId The node ID of the child.
* @param childEui64 The EUI64 of the child.
* @param childType The node type of the child.
*/
ezspChildJoinHandler(index: number, joining: boolean, childId: NodeId, childEui64: Eui64, childType: EmberNodeType): void;
/**
* Sends a ZDO energy scan request. This request may only be sent by the current
* network manager and must be unicast, not broadcast. See ezsp-utils.h for
* related macros emberSetNetworkManagerRequest() and
* emberChangeChannelRequest().
* @param target The network address of the node to perform the scan.
* @param scanChannels uint32_t A mask of the channels to be scanned
* @param scanDuration uint8_t How long to scan on each channel.
* Allowed values are 0..5, with the scan times as specified by 802.15.4 (0 = 31ms, 1 = 46ms, 2 = 77ms, 3 = 138ms, 4 = 261ms, 5 = 507ms).
* @param scanCount uint16_t The number of scans to be performed on each channel (1..8).
* @returns An SLStatus value indicating success or the reason for failure.
*/
ezspEnergyScanRequest(target: NodeId, scanChannels: number, scanDuration: number, scanCount: number): Promise<SLStatus>;
/**
* Returns the current network parameters.
* @returns An SLStatus value indicating success or the reason for failure.
* @returns EmberNodeType * An EmberNodeType value indicating the current node type.
* @returns EmberNetworkParameters * The current network parameters.
*/
ezspGetNetworkParameters(): Promise<[SLStatus, nodeType: EmberNodeType, parameters: EmberNetworkParameters]>;
/**
* Returns the current radio parameters based on phy index.
* @param phyIndex uint8_t Desired index of phy interface for radio parameters.
* @returns An SLStatus value indicating success or the reason for failure.
* @returns EmberMultiPhyRadioParameters * The current radio parameters based on provided phy index.
*/
ezspGetRadioParameters(phyIndex: number): Promise<[SLStatus, parameters: EmberMultiPhyRadioParameters]>;
/**
* Returns information about the children of the local node and the parent of
* the local node.
* @returns uint8_t The number of children the node currently has.
* @returns The parent's EUI64. The value is undefined for nodes without parents (coordinators a