/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); DeserializeInt8(); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _eui64 = deserializer.DeserializeEmberEui64(); _keyData = deserializer.DeserializeEmberKeyData(); _incomingFrameCounter = deserializer.DeserializeUInt32(); _countdownTimerMs = deserializer.DeserializeUInt32(); }
public void TestDeserialize_IEEE_ADDRESS() { byte[] valIn = { 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12 }; IeeeAddress valOut = new IeeeAddress("1234567890123456"); TestDeserialize(valIn, valOut, DataType.IEEE_ADDRESS); }
public void IsEqual() { IeeeAddress address1 = new IeeeAddress("17880100dc880b"); IeeeAddress address2 = new IeeeAddress("17880100dc880b"); Assert.True(address1.Equals(address2)); }
public EzspGetParentChildParametersResponse(int[] inputBuffer) : base(inputBuffer) { _childCount = deserializer.DeserializeUInt8(); _parentEui64 = deserializer.DeserializeEmberEui64(); _parentNodeId = deserializer.DeserializeUInt16(); }
public EzspIncomingManyToOneRouteRequestHandler(int[] inputBuffer) : base(inputBuffer) { _source = deserializer.DeserializeUInt16(); _longId = deserializer.DeserializeEmberEui64(); _cost = deserializer.DeserializeUInt8(); }
/// <summary> /// Serializes an IeeeAddress <seealso cref="IeeeAddress"/> /// </summary> /// <param name="address">The IeeeAddress <seealso cref="IeeeAddress"/></param> protected void SerializeIeeeAddress(IeeeAddress address) { for (int cnt = 7; cnt >= 0; cnt--) { _buffer[_length++] = address.GetAddress()[cnt]; } }
public ISet <IeeeAddress> ReadNetworkNodes() { ISet <IeeeAddress> nodes = new HashSet <IeeeAddress>(); try { if (Directory.Exists(_dirname)) { var jsonFiles = Directory.EnumerateFiles(_dirname, "*.json"); foreach (string file in jsonFiles) { try { IeeeAddress address = new IeeeAddress(file.Substring(file.Length - (16 + 5), 16)); nodes.Add(address); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(nodes); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _gpdIeeeAddress = deserializer.DeserializeEmberEui64(); _sourceId = deserializer.DeserializeUInt32(); _applicationId = deserializer.DeserializeEmberGpApplicationId(); _endpoint = deserializer.DeserializeUInt8(); }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); _data = DeserializeData(); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _bitmask = deserializer.DeserializeEmberInitialSecurityBitmask(); _preconfiguredKey = deserializer.DeserializeEmberKeyData(); _networkKey = deserializer.DeserializeEmberKeyData(); _networkKeySequenceNumber = deserializer.DeserializeUInt8(); _preconfiguredTrustCenterEui64 = deserializer.DeserializeEmberEui64(); }
public EzspGetChildDataResponse(int[] inputBuffer) : base(inputBuffer) { _status = deserializer.DeserializeEmberStatus(); _childId = deserializer.DeserializeUInt16(); _childEui64 = deserializer.DeserializeEmberEui64(); _childType = deserializer.DeserializeEmberNodeType(); }
/// <summary> /// Updates ZigBeeNode and adds it to the ZigBeeNetworkManager /// /// <param name="ieeeAddress">the <see cref="IeeeAddress"> of the newly announced node</param> /// <param name="networkAddress">the network address of the newly announced node</param> /// </summary> private void AddNode(IeeeAddress ieeeAddress, ushort networkAddress) { Log.Debug("{IeeeAddress}: NWK Discovery add node {NetworkAddress}", ieeeAddress, networkAddress); ZigBeeNode node = new ZigBeeNode(_networkManager, ieeeAddress, networkAddress); node.SetNodeState(ZigBeeNodeState.ONLINE); _networkManager.UpdateNode(node); }
/// <summary> /// Starts a discovery on a node. This will send a <see cref="NetworkAddressRequest"/> as a broadcast and will receive /// the response to trigger a full discovery. /// /// <param name="ieeeAddress">the <see cref="IeeeAddress"/> of the node to discover</param> /// </summary> public void RediscoverNode(IeeeAddress ieeeAddress) { if (!_initialized) { Log.Debug("Network discovery task: can't perform rediscovery on {IeeeAddress} until initialization complete.", ieeeAddress); return; } Task.Run(async() => { Log.Debug("{IeeeAddress}: NWK Discovery starting node rediscovery", ieeeAddress); int retries = 0; try { do { if (Thread.CurrentThread.ThreadState == ThreadState.WaitSleepJoin) { break; } NetworkAddressRequest request = new NetworkAddressRequest(); request.IeeeAddr = ieeeAddress; request.RequestType = 0; request.StartIndex = 0; request.DestinationAddress = new ZigBeeEndpointAddress(ZigBeeBroadcastDestination.GetBroadcastDestination(BroadcastDestination.BROADCAST_RX_ON).Key); CommandResult response = await _networkManager.SendTransaction(request, request); NetworkAddressResponse nwkAddressResponse = response.GetResponse <NetworkAddressResponse>(); if (nwkAddressResponse != null && nwkAddressResponse.Status == ZdoStatus.SUCCESS) { AddNode(nwkAddressResponse.IeeeAddrRemoteDev, nwkAddressResponse.NwkAddrRemoteDev); StartNodeDiscovery(nwkAddressResponse.NwkAddrRemoteDev); break; } // We failed with the last request. Wait a bit then retry try { Log.Debug("{IeeeAddress}: NWK Discovery node rediscovery request failed. Wait before retry.", ieeeAddress); await Task.Delay(_retryPeriod); } catch (Exception) { break; } } while (retries++ < _retryCount); } catch (Exception e) { Log.Debug("NWK Discovery error in rediscoverNode ", e); } Log.Debug("{IeeeAddress}: NWK Discovery finishing node rediscovery", ieeeAddress); }); }
public void Deserialize(IZigBeeDeserializer deserializer) { NeighborAddress = deserializer.ReadZigBeeType <IeeeAddress>(DataType.IEEE_ADDRESS); Coordinate1 = deserializer.ReadZigBeeType <ushort>(DataType.UNSIGNED_16_BIT_INTEGER); Coordinate2 = deserializer.ReadZigBeeType <ushort>(DataType.UNSIGNED_16_BIT_INTEGER); Coordinate3 = deserializer.ReadZigBeeType <ushort>(DataType.UNSIGNED_16_BIT_INTEGER); Rssi = deserializer.ReadZigBeeType <byte>(DataType.UNSIGNED_8_BIT_INTEGER); MeasurementCount = deserializer.ReadZigBeeType <byte>(DataType.UNSIGNED_8_BIT_INTEGER); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _shortId = deserializer.DeserializeUInt16(); _averageLqi = deserializer.DeserializeUInt8(); _inCost = deserializer.DeserializeUInt8(); _outCost = deserializer.DeserializeUInt8(); _age = deserializer.DeserializeUInt8(); _longId = deserializer.DeserializeEmberEui64(); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _type = deserializer.DeserializeEmberBindingType(); _local = deserializer.DeserializeUInt8(); _clusterId = deserializer.DeserializeUInt16(); _remote = deserializer.DeserializeUInt8(); _identifier = deserializer.DeserializeEmberEui64(); _uint8_t = deserializer.DeserializeUInt8(); }
/** * The Get Device Configuration Command * * @param targetAddress {@link IeeeAddress} Target Address * @return the Task<CommandResult> command result Task */ public Task <CommandResult> GetDeviceConfigurationCommand(IeeeAddress targetAddress) { GetDeviceConfigurationCommand command = new GetDeviceConfigurationCommand(); // Set the fields command.TargetAddress = targetAddress; return(Send(command)); }
/** * The Request Own Location Command * * @param requestingAddress {@link IeeeAddress} Requesting Address * @return the Task<CommandResult> command result Task */ public Task <CommandResult> RequestOwnLocationCommand(IeeeAddress requestingAddress) { RequestOwnLocationCommand command = new RequestOwnLocationCommand(); // Set the fields command.RequestingAddress = requestingAddress; return(Send(command)); }
public EzspChildJoinHandler(int[] inputBuffer) : base(inputBuffer) { _index = deserializer.DeserializeUInt8(); _joining = deserializer.DeserializeBool(); _childId = deserializer.DeserializeUInt16(); _childEui64 = deserializer.DeserializeEmberEui64(); _childType = deserializer.DeserializeEmberNodeType(); }
public EzspTrustCenterJoinHandler(int[] inputBuffer) : base(inputBuffer) { _newNodeId = deserializer.DeserializeUInt16(); _newNodeEui64 = deserializer.DeserializeEmberEui64(); _status = deserializer.DeserializeEmberDeviceUpdate(); _policyDecision = deserializer.DeserializeEmberJoinDecision(); _parentOfNewNodeId = deserializer.DeserializeUInt16(); }
/// <summary> /// Deserialise the contents of the EZSP structure. </summary> public void Deserialize(EzspDeserializer deserializer) { _bitmask = deserializer.DeserializeEmberKeyStructBitmask(); _type = deserializer.DeserializeEmberKeyType(); _key = deserializer.DeserializeEmberKeyData(); _outgoingFrameCounter = deserializer.DeserializeUInt32(); _incomingFrameCounter = deserializer.DeserializeUInt32(); _sequenceNumber = deserializer.DeserializeUInt8(); _partnerEUI64 = deserializer.DeserializeEmberEui64(); }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); int numberOfAddresses = DeserializeInt8(); _addressList = DeserializeInt16Array(numberOfAddresses); }
/** * Get Node IEEE address * * @param networkAddress the network address of the node * @return true if the message was processed ok */ private async Task <bool> GetIeeeAddress(ushort networkAddress) { try { byte startIndex = 0; int totalAssociatedDevices = 0; List <ushort> associatedDevices = new List <ushort>(); IeeeAddress ieeeAddress = null; do { // Request extended response, start index for associated list is 0 IeeeAddressRequest ieeeAddressRequest = new IeeeAddressRequest(); ieeeAddressRequest.DestinationAddress = new ZigBeeEndpointAddress(networkAddress); ieeeAddressRequest.RequestType = 1; ieeeAddressRequest.StartIndex = startIndex; ieeeAddressRequest.NwkAddrOfInterest = networkAddress; CommandResult response = await _networkManager.SendTransaction(ieeeAddressRequest, ieeeAddressRequest); if (response.IsError()) { return(false); } IeeeAddressResponse ieeeAddressResponse = response.GetResponse <IeeeAddressResponse>(); _logger.Debug("{NetworkAddress}: NWK Discovery IeeeAddressRequest returned {IeeeAddress}", networkAddress, ieeeAddressResponse); if (ieeeAddressResponse != null && ieeeAddressResponse.Status == ZdoStatus.SUCCESS) { ieeeAddress = ieeeAddressResponse.IeeeAddrRemoteDev; if (startIndex.Equals(ieeeAddressResponse.StartIndex)) { associatedDevices.AddRange(ieeeAddressResponse.NwkAddrAssocDevList); startIndex += (byte)ieeeAddressResponse.NwkAddrAssocDevList.Count; totalAssociatedDevices = ieeeAddressResponse.NwkAddrAssocDevList.Count; } } } while (startIndex < totalAssociatedDevices); AddNode(ieeeAddress, networkAddress); // Start discovery for any associated nodes foreach (ushort deviceNetworkAddress in associatedDevices) { StartNodeDiscovery(deviceNetworkAddress); } } catch (Exception e) { _logger.Debug("NWK Discovery Error in checkIeeeAddressResponse {Error}", e); } return(true); }
public void SerializeEmberEui64(IeeeAddress address) { _buffer[_length++] = address.GetAddress()[0]; _buffer[_length++] = address.GetAddress()[1]; _buffer[_length++] = address.GetAddress()[2]; _buffer[_length++] = address.GetAddress()[3]; _buffer[_length++] = address.GetAddress()[4]; _buffer[_length++] = address.GetAddress()[5]; _buffer[_length++] = address.GetAddress()[6]; _buffer[_length++] = address.GetAddress()[7]; }
/// <summary> /// Method for deserializing the fields for the response </summary> public void Deserialize(int[] incomingData) { InitializeDeserializer(incomingData); _ieeeAddress = DeserializeIeeeAddress(); _networkAddress = DeserializeInt16(); _receiveOptions = DeserializeReceiveOptions(); int bootloaderMessageType = DeserializeInt8(); _blockNumber = DeserializeInt8(); _targetAddress = DeserializeIeeeAddress(); }
/** * Tells the stack whether or not the normal interval between retransmissions of a retried unicast message should be * increased by EMBER_INDIRECT_TRANSMISSION_TIMEOUT. The interval needs to be increased when sending to a sleepy * node so that the message is not retransmitted until the destination has had time to wake up and poll its parent. * The stack will automatically extend the timeout: * <ul> * <li>For our own sleepy children. * <li>When an address response is received from a parent on behalf of its child. * <li>When an indirect transaction expiry route error is received. * <li>When an end device announcement is received from a sleepy node. * </ul> * * @param remoteEui64 the {@link IeeeAddress} of the remote node * @param extendedTimeout true if the node should be set with an extended timeout * @return the {@link ZigBeeStatus} of the request */ public ZigBeeStatus SetExtendedTimeout(IeeeAddress remoteEui64, bool extendedTimeout) { EzspSetExtendedTimeoutRequest request = new EzspSetExtendedTimeoutRequest(); request.SetRemoteEui64(remoteEui64); request.SetExtendedTimeout(extendedTimeout); IEzspTransaction transaction = _protocolHandler.SendEzspTransaction(new EzspSingleResponseTransaction(request, typeof(EzspSetExtendedTimeoutResponse))); EzspSetExtendedTimeoutResponse response = (EzspSetExtendedTimeoutResponse)transaction.GetResponse(); return((response == null) ? ZigBeeStatus.FAILURE : ZigBeeStatus.SUCCESS); }
/** * The Report RSSI Measurements Command * * @param reportingAddress {@link IeeeAddress} Reporting Address * @param numberOfNeighbors {@link byte} Number of Neighbors * @param neighborsInformation {@link List<NeighborInformation>} Neighbors Information * @return the Task<CommandResult> command result Task */ public Task <CommandResult> ReportRSSIMeasurementsCommand(IeeeAddress reportingAddress, byte numberOfNeighbors, List <NeighborInformation> neighborsInformation) { ReportRSSIMeasurementsCommand command = new ReportRSSIMeasurementsCommand(); // Set the fields command.ReportingAddress = reportingAddress; command.NumberOfNeighbors = numberOfNeighbors; command.NeighborsInformation = neighborsInformation; return(Send(command)); }
/** * The Send Pings Command * * @param targetAddress {@link IeeeAddress} Target Address * @param numberRSSIMeasurements {@link byte} Number RSSI Measurements * @param calculationPeriod {@link ushort} Calculation Period * @return the Task<CommandResult> command result Task */ public Task <CommandResult> SendPingsCommand(IeeeAddress targetAddress, byte numberRSSIMeasurements, ushort calculationPeriod) { SendPingsCommand command = new SendPingsCommand(); // Set the fields command.TargetAddress = targetAddress; command.NumberRSSIMeasurements = numberRSSIMeasurements; command.CalculationPeriod = calculationPeriod; return(Send(command)); }
public EzspIncomingRouteRecordHandler(int[] inputBuffer) : base(inputBuffer) { _source = deserializer.DeserializeUInt16(); _sourceEui = deserializer.DeserializeEmberEui64(); _lastHopLqi = deserializer.DeserializeUInt8(); _lastHopRssi = deserializer.DeserializeInt8S(); int relayCount = deserializer.DeserializeUInt8(); _relayList = deserializer.DeserializeUInt16Array(relayCount); }