Sadaf
Sadaf

Reputation: 257

COAP as a Streaming Source

I am currently working on IOT Coap protocol.I accessed server on local host through copper firefox plugin. Then i Added resouce having "GET" functionality in server. After that i made its client as a streaming source. Here is the code of client streaming

 class customReceiver(test:String) extends  Receiver[String](StorageLevel.MEMORY_AND_DISK_2) with Logging with Serializable { 
   @volatile private var stopped = false
   override def onStart() {

      val client = new CoapClient("ip/resource")
      var text = client.get().getResponseText();  
      store(text)
   }
   override def onStop(): Unit = synchronized { 
      try
      {
         stopped = true
      }
      catch
      {
         case e: Exception => println("exception caught: " + e);
      }
   }
 }

but i am facing a problem. During streaming it just read a resource once. after that it fetches all empty rdd and completes its batches. Meanwhile if resource changes its value it doesn't read that. are i doing something wrong? or is there exists any other functionality to read whenever resource get changed that i can handle in my Custom receiver.? or any idea about how to GET value continuously during streaming?

Any help is much awaited and appreciated. Thanks

Upvotes: 0

Views: 975

Answers (2)

Avadhana Technologies
Avadhana Technologies

Reputation: 692

Streaming of data is application implementation.

  • 1] You can subscribe the resource as observer. The observer functionality has to be implemented in your application.
  • 2] You can continuously send data in interval using PUT functionality.

A good OBSERVE example is provided in libcoap, where client (firefox copper) observes the "time" resource of server (coap-server). coap-server continuously sends CON message of time and date to client, since time changes very second. In turn client send ACK message.

Also CoAP combined with TCP functionality is better suitable for streaming of data.

Upvotes: 3

Jiloc
Jiloc

Reputation: 3638

There is an observe functionality: it enables CoAP clients to "subscribe" to resources and servers to send updates to subscribed clients whenerver the resource the client subscribes to get changed over a period of time. Here is the IEFT draft.

Upvotes: 1

Related Questions