Exemple #1
0
 def render_GET(self, request):
     data = []
     self.root.generateResourceList(data, "")
     payload = ",".join(data)
     print payload
     response = coap.Message(code=coap.CONTENT, payload=payload)
     response.opt.content_format = coap.media_types_rev[
         'application/link-format']
     return defer.succeed(response)
Exemple #2
0
 def responseReady(self, d, request):
     log.msg('response ready. sending...')
     payload = "Three rings for the elven kings under the sky, seven rings for dwarven lords in their halls of stone, nine rings for mortal men doomed to die, one ring for the dark lord on his dark throne."
     response = coap.Message(code=coap.CONTENT, payload=payload)
     d.callback(response)
Exemple #3
0
 def render_PUT(self, request):
     print 'PUT payload: ' + request.payload
     payload = "Mr. and Mrs. Dursley of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much."
     response = coap.Message(code=coap.CHANGED, payload=payload)
     return defer.succeed(response)
Exemple #4
0
 def render_GET(self, request):
     payload = " Now I lay me down to sleep, I pray the Lord my soul to keep, If I shall die before I wake, I pray the Lord my soul to take."
     response = coap.Message(code=coap.CONTENT, payload=payload)
     return defer.succeed(response)
Exemple #5
0
 def render_GET(self, request):
     response = coap.Message(code=coap.CONTENT,
                             payload='%d' % (self.counter, ))
     self.counter += 1
     return defer.succeed(response)
Exemple #6
0
 def render_GET(self, request):
     response = coap.Message(
         code=coap.CONTENT,
         payload=datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
     return defer.succeed(response)