/// <summary> /// This method composes a UDP call to the simulator to acquire the device list. /// </summary> private void RequestDeviceList() { string serverIP = __IpAddress; __coapClient.Initialize(serverIP, __ServerPort); __coapClient.AckTimeout = __Timeout; __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); __coapClient.CoAPRequestReceived += new CoAPRequestReceivedHandler(OnCoAPRequestReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); //Send a NON request to get the temperature...in return we will get a NON request from the server coapReq = new CoAPRequest(this.ConfirmableMessageType, //CoAPMessageType.NON CoAPMessageCode.GET, HdkUtils.MessageId()); //hardcoded message ID as we are using only once string uriToCall = "coap://" + serverIP + ":" + __ServerPort + "/devices"; //"/sensors/temp";"/time";// coapReq.SetURL(uriToCall); __Token = DateTime.Now.ToString("HHmmss"); //Token value must be less than 8 bytes coapReq.Token = new CoAPToken(__Token); //A random token __coapClient.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); __Done.Close(); __Done = null; __coapClient.Shutdown(); __coapClient = null; }
private void AcknowledgeResponse(CoAPResponse coapResp) { string serverIP = __IpAddress; // Response handlers already set - leave them alone coapReq = new CoAPRequest(CoAPMessageType.ACK, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); __Token = DateTime.Now.ToString("HHmmss");//Token value must be less than 8 bytes coapReq.Token = coapResp.Token; string blat = coapReq.ToString(); // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 FileLogger.Write("About to send CoAP ACK request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); }
/// <summary> /// Send CoAP request to the server /// </summary> public override void Send() { string device = __IpAddress; string serverIP = "localhost"; __coapClient.Initialize(serverIP, __ServerPort); __coapClient.AckTimeout = __Timeout; __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); __coapClient.CoAPRequestReceived += new CoAPRequestReceivedHandler(OnCoAPRequestReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); //Send a NON request to get the temperature...in return we will get a NON request from the server coapReq = new CoAPRequest(this.ConfirmableMessageType, //CoAPMessageType.NON CoAPMessageCode.GET, HdkUtils.MessageId()); //hardcoded message ID as we are using only once string uriToCall = "coap://" + serverIP + ":" + __ServerPort + "/" + __IpAddress + "/.well-known/core"; //"/sensors/temp";"/time";// coapReq.SetURL(uriToCall); SetToken(); __coapClient.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); __Done.Close(); __Done = null; __coapClient.Shutdown(); __coapClient = null; }
/// <summary> /// Send the CoAP request to the server /// </summary> public override void Send() { string device = __IpAddress; string serverIP = "localhost"; __coapClient.Initialize(serverIP, __ServerPort); __coapClient.Initialize(serverIP, __ServerPort); __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType,//CoAPMessageType.NON, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + serverIP + ":" + __ServerPort + "/" + __IpAddress + __URI; coapReq.SetURL(uriToCall); SetToken(); // Send out the request. coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); __coapClient.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPError); }
public override void Send() { // If we can't establish a socket with a good login to the gateway api, then just return; bool gotSession = false; try { gotSession = CoApGatewaySessionManager.Instance.EstablishSession(); } catch (Exception noSession) { FileLogger.Write("Error obtaining session"); FileLogger.Write(noSession.Message); FileLogger.Write(noSession.StackTrace); this.ErrorResult = "Error obtaining session" + noSession.Message; } if (!gotSession) { FileLogger.Write("Session NOT Established"); return; } string serverIP = __IpAddress; // Set the response handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); SetToken(); // Send out the request. // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet header coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); coapReq.Timeout = GatewaySettings.Instance.RequestTimeout;////////////////////////////////////// CoApGatewaySessionManager.Instance.Client.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPError); }
public override void Send() { string serverIP = __IpAddress; __coapClient = new CoAPClientChannel(); __coapClient.Initialize(serverIP, __ServerPort); __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); __coapClient.CoAPRequestReceived += new CoAPRequestReceivedHandler(OnCoAPRequestReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); //Send a NON request to get the temperature...in return we will get a NON request from the server coapReq = new CoAPRequest(CoAPMessageType.RST, CoAPMessageCode.GET, HdkUtils.MessageId()); //hardcoded message ID as we are using only once string uriToCall = "coap://" + serverIP + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); __Token = DateTime.Now.ToString("HHmmss"); //Token value must be less than 8 bytes coapReq.Token = new CoAPToken(__Token); //A random token __coapClient.Send(coapReq); __Done.WaitOne(); __Done.Reset(); __Done.Close(); __Done = null; __coapClient.Shutdown(); __coapClient = null; }
public override void Send() { // If we can't establish a socket with a good login to the gateway api, then just return; if (!CoApGatewaySessionManager.Instance.EstablishSession()) { return; } string serverIP = __IpAddress; // Set the response handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPError); __URI = "/"; coapReq = new CoAPRequest(CoAPMessageType.CON, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); SetToken(); // Send out the request. // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 //////coapReq = new CoAPRequest(CoAPMessageType.CON, ////// CoAPMessageCode.EMPTY, ////// HdkUtils.MessageId()); //////string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress);// + ":" + __ServerPort + __URI; //////coapReq.SetURL(uriToCall); ////////SetToken(); //////// Send out the request. ////////coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPError); }
/// <summary> /// Perform a session request (acquire or terminate). /// </summary> /// <param name="messageCode">CoAPMessageCode.POST for establishing a session or oAPMessageCode.DELETE for terminating a session</param> /// <returns>a boolean indicating success or failure of the request</returns> private bool SessionCall(byte messageCode) { __TimedOut = true; __SessionRequestSucceeded = false; string token = GatewaySettings.Instance.SfdpToken; //api.coap-test.developer.ssni.com string serverIP = AbstractNetworkUtils.GetIPAddressFromHostname(GatewaySettings.Instance.GatewayURI).ToString(); __coapClient.Initialize(GatewaySettings.Instance.GatewayURI, __ServerPort); __coapClient.AckTimeout = __Timeout; __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPSessionResponseReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, messageCode, HdkUtils.MessageId()); string uriToCall = "coap://" + GatewaySettings.Instance.GatewayURI + ":" + __ServerPort + "/sessions?security=none";//?token=" //+ GatewaySettings.Instance.SfdpToken; //+ "&security=none"; coapReq.SetURL(uriToCall); byte[] zero = { 0x00 }; coapReq.AddOption(CoAPHeaderOption.CONTENT_FORMAT, zero); if (messageCode != CoAPMessageCode.DELETE) { coapReq.Payload = new CoAPPayload(GatewaySettings.Instance.SfdpToken); } SetToken(); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); // JJK - Change in v2.0.7 FileLogger.Write("About to send session request"); try { FileLogger.Write(coapReq.ToString()); } catch (Exception flErr) { FileLogger.Write(flErr.Message); } __coapClient.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); if (__TimedOut) { this.ErrorResult = "Request timed out"; FileLogger.Write(this.ErrorResult); } __coapClient.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPSessionResponseReceived); return(__SessionRequestSucceeded); }
public void StartObserving() { string serverIP = __IpAddress; // Set the response handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPObserveResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); SetToken(); string blat = coapReq.ToString(); byte[] observerOption = new byte[1]; observerOption[0] = 0; // Start observing coapReq.Options.AddOption(CoAPHeaderOption.OBSERVE, new byte[0]); //coapReq.Options.AddOption(CoAPHeaderOption.OBSERVE, observerOption); // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); __Observing = true; while (__Observing) { //FileLogger.Write(CoApGatewaySessionManager.Instance.Client.ToString()); Application.DoEvents(); Thread.Sleep(100); //__Done.WaitOne(GatewaySettings.Instance.RequestTimeout); } __Done.Reset(); }
/// <summary> /// /// </summary> /// <returns></returns> public new byte[] ToBytes() { string serverIP = __IpAddress; //coapsharp.Properties.Settings.Default.IpAddress;// "10.90.202.182";//"localhost"; coapReq = new CoAPRequest(this.ConfirmableMessageType, //CoAPMessageType.NON, CoAPMessageCode.GET, HdkUtils.MessageId()); //hardcoded message ID as we are using only once string uriToCall = "coap://" + serverIP + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); __Token = DateTime.Now.ToString("HHmmss"); //Token value must be less than 8 bytes coapReq.Token = new CoAPToken(__Token); //A random token byte[] b = __coapClient.ToBytes(coapReq); return(b); }
/// <summary> /// Send the PUT request /// </summary> public override void Send() { string serverIP = __IpAddress; // Set up the handlers CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.PUT, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); SetToken(); byte[] octet = new byte[1]; // As of this moment, the expectation is that the content is an octet stream. octet[0] = (byte)CoAPContentFormatOption.APPLICATION_OCTET_STREAM; // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 coapReq.Options.AddOption(CoAPHeaderOption.CONTENT_FORMAT, octet); coapReq.Payload = __Payload; FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); }
/// <summary> /// Send the request to the CoAP server. /// </summary> public override void Send() { string serverIP = __IpAddress; // Set the response handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.DELETE, HdkUtils.MessageId()); string uriToCall = "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + __ServerPort + __URI; coapReq.SetURL(uriToCall); SetToken(); // JJK - Changes in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + HdkUtils.UriFromMac(__IpAddress) + ":" + "4849" + __URI); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // JJK - end of Changes in v2.0.7 FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPError); }
/// <summary> /// Send the request to the CoAP server. /// </summary> public override void Send() { string device = __IpAddress; string serverIP = "localhost"; __coapClient.Initialize(serverIP, __ServerPort); __coapClient.Initialize(serverIP, __ServerPort); __coapClient.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPResponseReceived); __coapClient.CoAPError += new CoAPErrorHandler(OnCoAPError); coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.DELETE, HdkUtils.MessageId()); string uriToCall = "coap://" + serverIP + ":" + __ServerPort + "/" + __IpAddress + __URI; coapReq.SetURL(uriToCall); SetToken(); // Send out the request. byte[] octet = new byte[1]; // As of this moment, the expectation is that the content is an octet stream. octet[0] = (byte)CoAPContentFormatOption.APPLICATION_OCTET_STREAM; coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); coapReq.Options.AddOption(CoAPHeaderOption.CONTENT_FORMAT, octet); coapReq.Payload = __Payload; FileLogger.Write("About to send CoAP request"); FileLogger.Write(coapReq.ToString()); __coapClient.Send(coapReq); __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); __Done.Reset(); CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPError); }
/// <summary> /// Load resources associated with a specific device. /// This is the CoAP Gateway implementation of CoApDiscovery. /// </summary> /// <returns>a collection of CoApResource objects</returns> /// public override CoApResources LoadResources() { // If we can't establish a socket with a good login to the gateway api, then just return; bool gotSession = false; try { gotSession = CoApGatewaySessionManager.Instance.EstablishSession(); } catch (Exception noSession) { FileLogger.Write("Error obtaining session"); FileLogger.Write(noSession.Message); FileLogger.Write(noSession.StackTrace); this.ErrorResult = "Error obtaining session" + noSession.Message; } if (!gotSession) { FileLogger.Write("Session NOT Established"); return(null); } // This represents the device being examined. string serverIP = __IpAddress; // Set up the notification handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived += new CoAPResponseReceivedHandler(OnCoAPDiscoveryResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError += new CoAPErrorHandler(OnCoAPDiscoveryError); __TimedOut = true; // Discovery requires confirmation and a message type of GET coapReq = new CoAPRequest(this.ConfirmableMessageType, CoAPMessageCode.GET, HdkUtils.MessageId()); string uriToCall = "coap://" + UriFromMac(__IpAddress) + ":" + __ServerPort + "/.well-known/core";//"/.well-known/core"; coapReq.SetURL(uriToCall); SetToken(); // Send out the coap request // JJK - Change in v2.0.7 //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_SCHEME, "coap"); // make Proxy packet Change in v2.0.7 coapReq.Options.AddOption(CoAPHeaderOption.BLOCK2, new byte[] { CoAPBlockOption.BLOCK_SIZE_128 }); //coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://SSN001350050047dc9a.SG.YEL01.SSN.SSNSGS.NET:4849/.well-known/core"); coapReq.Options.AddOption(CoAPHeaderOption.PROXY_URI, "coap://" + UriFromMac(__IpAddress) + ":" + "4849" + "/.well-known/core"); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_HOST); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_QUERY); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PATH); coapReq.Options.RemoveOption(CoAPHeaderOption.URI_PORT); coapReq.Options.RemoveOption(CoAPHeaderOption.CONTENT_FORMAT); // end of Changes in v2.0.7 FileLogger.Write("About to send Gateway resource request"); FileLogger.Write(coapReq.ToString()); CoApGatewaySessionManager.Instance.Client.Send(coapReq); CoApDiscoveryResponse response = null; // Wait for a response from the discovery request. // Time out after the pre-defined maximum wait time. __Done.WaitOne(GatewaySettings.Instance.RequestTimeout); response = this.DiscoveryResponse; // Reset the wait object __Done.Reset(); if (__TimedOut) { this.ErrorResult = "Request timed out"; } // Remove event handlers. CoApGatewaySessionManager.Instance.Client.CoAPResponseReceived -= new CoAPResponseReceivedHandler(OnCoAPDiscoveryResponseReceived); CoApGatewaySessionManager.Instance.Client.CoAPError -= new CoAPErrorHandler(OnCoAPDiscoveryError); return(response.Resources); }