public void StartRequest( UInt16 panId, Byte logicalChannel, Byte channelPage, UInt16 startTime, byte beaconOrder, byte superframeOrder, bool panCoordinator, bool batteryLifeExtension, bool coordRealignment, SecurityOptions coordRealignSecutiryOptions, SecurityOptions beaconSecurityOptions, StartConfirmHandler handler) { TaskStartRequest task = new TaskStartRequest( panId, logicalChannel, channelPage, startTime, beaconOrder, superframeOrder, panCoordinator, batteryLifeExtension, coordRealignment, coordRealignSecutiryOptions, beaconSecurityOptions, handler); if (!_taskQueue.Add(task) && handler != null) { handler.Invoke(this, MacEnum.Congested); } }
public TaskStartRequest( UInt16 panId, Byte logicalChannel, Byte channelPage, UInt16 startTime, byte beaconOrder, byte superframeOrder, bool panCoordinator, bool batteryLifeExtension, bool coordRealignment, SecurityOptions coordRealignSecutiryOptions, SecurityOptions beaconSecurityOptions, StartConfirmHandler handler) : base(TaskType.StartRequest) { this.panId = panId; this.logicalChannel = logicalChannel; this.channelPage = channelPage; this.startTime = startTime; this.beaconOrder = beaconOrder; this.superframeOrder = superframeOrder; this.panCoordinator = panCoordinator; this.batteryLifeExtension = batteryLifeExtension; this.coordRealignment = coordRealignment; this.coordRealignSecutiryOptions = coordRealignSecutiryOptions; this.beaconSecurityOptions = beaconSecurityOptions; this.handler = handler; }
/// <summary> /// Starts a new network as coordinator. There shall be only one coordinator per network. /// In the current implementation, the PAN-ID is derived from the lower 16 bits of the network ID. /// The channel is automatically selected. /// </summary> /// <param name="netId">unique network ID</param> /// <param name="handler">handlder for result</param> public void StartRequest( UInt16 panId, StartConfirmHandler handler) { if (_running || _scanning) { if (handler != null) handler.Invoke(_net, Status.Busy, 0, 0, 0); return; } _running = true; _panId = panId; _startConfirmHandler = handler; StartScanning(ScanHandlerStartRequest); }
/// <summary> /// Starts a new network as coordinator. There shall be only one coordinator per network. /// In the current implementation, the PAN-ID is derived from the lower 16 bits of the network ID. /// The channel is automatically selected. /// </summary> /// <param name="netId">unique network ID</param> /// <param name="handler">handlder for result</param> public void StartRequest( UInt16 panId, StartConfirmHandler handler) { if (_running || _scanning) { if (handler != null) { handler.Invoke(_net, Status.Busy, 0, 0, 0); } return; } _running = true; _panId = panId; _startConfirmHandler = handler; StartScanning(ScanHandlerStartRequest); }
/// <summary> /// To start the network layer /// </summary> /// <param name="panId">Pan ID of the network to set on Mac layer</param> /// <param name="panCoordinator">True if this node is the network coordinator</param> /// <param name="logicalChannel">Logical channel to use</param> /// <param name="channelPage">Channel page to use</param> /// <param name="neighours">Set of neighbors to bootstrap. Not used when started as network coordinator</param> /// <param name="handler">Handler for confirmation message</param> public void Start(UInt16 panId, bool netCoordinator, byte logicalChannel, byte channelPage, UInt16[] neighours, StartConfirmHandler handler) { if (_isRunning) { if (handler != null) handler.Invoke(this, Status.Busy, 0); return; } _isRunning = true; _panId = panId; _startConfirmHandler = handler; if (netCoordinator) { _addrShort = cCoordinatorShortAddr; _addrServer = new AddressAndDiscoveryServer(this); // always exists if isAddrServer is true } else { _addrShort = cUnallocatedShortAddr; _addrServer = null; } _isAddrServer = netCoordinator; _mac.DataIndication = MacDataIndHandler; _mac.GetDeviceAddress(out _addrExt); PibValue value = new PibValue(); value.Int = _addrShort; _mac.SetRequest(PibAttribute.macShortAddress, 0, value, null); AutoResetEvent startEvent = new AutoResetEvent(false); Status result = Status.Error; _mac.StartRequest(_panId, logicalChannel, channelPage, 0, 15, 0, netCoordinator, false, false, new SecurityOptions(), new SecurityOptions(), delegate( IMacMgmtSap sender, MacEnum status) { if (status == MacEnum.Success) result = Status.Success; startEvent.Set(); }); startEvent.WaitOne(); if (result == Status.Success && !_isAddrServer) { _getAddressNeighbors = neighours; _getAddressCancel = false; _getAddressEvent.Reset(); _getAddressThread = new Thread(GetAddressThread); #if !MICROFRAMEWORK _getAddressThread.IsBackground = true; #endif _getAddressThread.Start(); } else { FinalizeStartup(result); } }
/// <summary> /// Starts a new network as coordinator. There shall be only one coordinator per network. /// In the current implementation, the PAN-ID is derived from the lower 16 bits of the network ID. /// The channel is automatically selected. /// </summary> /// <param name="netId">unique network ID</param> /// <param name="handler">handlder for result</param> public void StartRequest( UInt16 panId, StartConfirmHandler handler) { _mgmt.StartRequest(panId, handler); }