private void InitRequestTxOptions() { var options = new TxOptions(); options.Hash = "BDE5FAA4F287353E65B3AC603F538DE091F1D8F4723A120BD7D930C5C4668FE2"; pgRequestTxOptions.SelectedObject = options; }
public void DataRequest( MacAddressingMode srcAddrMode, MacAddress dstAddr, UInt16 dstPanId, ref Frame msdu, Byte msduHandle, TxOptions options, SecurityOptions securityOptions, DataConfirmHandler handler) { TaskDataRequest task = new TaskDataRequest( srcAddrMode, dstAddr, dstPanId, msdu, msduHandle, options, securityOptions, handler); if (!_taskQueue.Add(task)) { Frame.Release(ref msdu); if (handler != null) { handler.Invoke(this, msduHandle, MacEnum.Congested); } } msdu = null; // in any case, remove frame ownership from caller }
public void TestRequestTx_Invalid() { var deferred = new Task(() => { }); MessageResult <TxResponse> response = null; var options = new TxOptions(); options.Hash = "abcxyz"; _remote.RequestTx(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); Assert.IsInstanceOfType(response.Exception, typeof(InvalidHashException)); }
public void TestRequestTx() { var deferred = new Task(() => { }); _remote = new Remote(ServerUrl); MessageResult <TxResponse> response = null; _remote.Connect(r => { var options = new TxOptions(); // tx for active account "jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr" in test server options.Hash = "3B92FD6E5A950BEFC7DB6F220CF162236148F01F8FA61C3CFA11CD1ECCC195CC"; var req = _remote.RequestTx(options); req.Submit(r1 => { response = r1; deferred.Start(); }); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var tx = response.Result; Assert.IsNotNull(tx); Assert.AreEqual("3B92FD6E5A950BEFC7DB6F220CF162236148F01F8FA61C3CFA11CD1ECCC195CC", tx.Hash); Assert.AreEqual("jHb9CJAWyB4jr91VRWn96DkukG4bwdtyTh", tx.Account); Assert.AreEqual("jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", tx.Destination); Assert.AreEqual(new Amount { Currency = "SWT", Issuer = "", Value = "10000" }, tx.Amount); Assert.AreEqual(TransactionType.Payment, tx.TransactionType); var txr = tx.TxResult as SentTxResult; Assert.IsNotNull(txr); Assert.AreEqual("3B92FD6E5A950BEFC7DB6F220CF162236148F01F8FA61C3CFA11CD1ECCC195CC", txr.Hash); Assert.AreEqual("jMw3xrkX2ySwdQiEorymyuTLUSSa85wvSr", txr.CounterParty); Assert.AreEqual(new Amount { Currency = "SWT", Issuer = "", Value = "10000" }, txr.Amount); Assert.AreEqual(TxResultType.Sent, txr.Type); }
public void TestRequestTxResponse() { var remote = new Remote(""); remote.SetMockServer(new MockServer(remote, "RequestTx.json")); MessageResult <TxResponse> response = null; var deferred = new Task(() => { }); var options = new TxOptions(); options.Hash = "8CF8868AE692CCC7B6E0882A3FF06DD6E0757EB73549473F2C4F5BE7A5161B67"; remote.RequestTx(options).Submit(r => { response = r; deferred.Start(); }); Assert.IsTrue(deferred.Wait(DeferredWaitingTime)); Assert.IsNotNull(response); var tx = response.Result; Assert.IsNotNull(tx); Assert.AreEqual("j4VnosbcpqPMRf1kMoyvfxjmWyUfVJGWSB", tx.Account); Assert.AreEqual(new Amount { Currency = "SWT", Issuer = "", Value = "30" }, tx.Amount); Assert.AreEqual("jNkJTKfhkQF2dLUurYQCyqyyGkYywn1tQm", tx.Destination); Assert.AreEqual(32746, tx.Sequence); Assert.AreEqual(TransactionType.Payment, tx.TransactionType); Assert.AreEqual("8CF8868AE692CCC7B6E0882A3FF06DD6E0757EB73549473F2C4F5BE7A5161B67", tx.Hash); Assert.IsTrue(tx.Validated); Assert.IsNotNull(tx.Meta); var txResult = tx.TxResult as SentTxResult; Assert.IsNotNull(txResult); Assert.AreEqual(TxResultType.Sent, txResult.Type); Assert.AreEqual("jNkJTKfhkQF2dLUurYQCyqyyGkYywn1tQm", txResult.CounterParty); Assert.AreEqual("8CF8868AE692CCC7B6E0882A3FF06DD6E0757EB73549473F2C4F5BE7A5161B67", txResult.Hash); }
public TaskDataRequest( MacAddressingMode srcAddrMode, MacAddress dstAddr, UInt16 dstPANId, Frame msdu, Byte msduHandle, TxOptions options, SecurityOptions securityOptions, DataConfirmHandler handler) : base(TaskType.DataRequest) { this.srcAddrMode = srcAddrMode; this.dstAddr = dstAddr; this.dstPANId = dstPANId; this.msdu = msdu; this.msduHandle = msduHandle; this.options = options; this.securityOptions = securityOptions; this.handler = handler; }
/// <summary> /// Send a Mac SDU using context information. SrcAddr is automatically choosen. /// </summary> /// <param name="msdu">The frame to sent.</param> /// <param name="context">Sent context. If null, frame is broadcasted</param> private void MacDataRequestReal( bool useExtAddr, UInt16 nextHopAddrShort, UInt64 nextHopAddrExt, ref Frame sdu, Byte sduHandle, DataConfirmHandler handler) { // srcAddr: always use short addr when available MacAddressingMode srcAddrMode = new MacAddressingMode(); if (_addrShort == cUnallocatedShortAddr) srcAddrMode = MacAddressingMode.ExtendedAddress; else srcAddrMode = MacAddressingMode.ShortAddress; MacAddress dstAddr = new MacAddress(); if (useExtAddr) dstAddr.ExtendedAddress = nextHopAddrExt; else dstAddr.ShortAddress = nextHopAddrShort; byte msduHandle; Mac.DataConfirmHandler macHandler; bool broadcast = (!useExtAddr) && IsMulticast(nextHopAddrShort); if (!broadcast || handler != null) { // need a send context MessageContext.Context context = _messageContext.GetFreeContext(); if (context == null) { // busy if (handler != null) handler.Invoke(_net, sduHandle, Status.Busy); Frame.Release(ref sdu); return; } context.useExtAddr = useExtAddr; context.nextHopShort = nextHopAddrShort; context.nextHopExt = nextHopAddrExt; context.dataSduHandle = sduHandle; context.dataHandler = handler; macHandler = MacDataConfirmHandler; msduHandle = context.macSduHandle; } else { macHandler = null; msduHandle = MessageContext.cHandleDontCare; } TxOptions tx = new TxOptions(); if (!broadcast) tx.AcknowledgedTransmission = true; _mac.DataRequest( srcAddrMode, dstAddr, _panId, ref sdu, msduHandle, tx, new SecurityOptions(), macHandler); Frame.Release(ref sdu); }