Merge pull request #4 from michieldwitte/master
removed forced logging, set receiver thread as daemon, Let the outbound payload be binary
This commit is contained in:
commit
6b74876f66
5 changed files with 9 additions and 21 deletions
|
@ -14,18 +14,13 @@ from coapthon.messages.message import Message
|
|||
from coapthon.messages.request import Request
|
||||
from coapthon.messages.response import Response
|
||||
from coapthon.serializer import Serializer
|
||||
from coapthon.utils import create_logging
|
||||
import collections
|
||||
|
||||
|
||||
__author__ = 'Giacomo Tanganelli'
|
||||
|
||||
|
||||
if not os.path.isfile("logging.conf"):
|
||||
create_logging()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
|
||||
|
||||
|
||||
class CoAP(object):
|
||||
|
@ -174,6 +169,7 @@ class CoAP(object):
|
|||
|
||||
if self._receiver_thread is None or not self._receiver_thread.isAlive():
|
||||
self._receiver_thread = threading.Thread(target=self.receive_datagram)
|
||||
self._receiver_thread.daemon = True
|
||||
self._receiver_thread.start()
|
||||
|
||||
def _start_retransmission(self, transaction, message):
|
||||
|
|
|
@ -17,15 +17,12 @@ from coapthon.messages.message import Message
|
|||
from coapthon.messages.request import Request
|
||||
from coapthon.resources.resource import Resource
|
||||
from coapthon.serializer import Serializer
|
||||
from coapthon.utils import Tree, create_logging
|
||||
from coapthon.utils import Tree
|
||||
|
||||
__author__ = 'Giacomo Tanganelli'
|
||||
|
||||
if not os.path.isfile("logging.conf"):
|
||||
create_logging()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
|
||||
|
||||
|
||||
class CoAP(object):
|
||||
|
|
|
@ -21,16 +21,12 @@ from coapthon.messages.request import Request
|
|||
from coapthon.resources.remoteResource import RemoteResource
|
||||
from coapthon.resources.resource import Resource
|
||||
from coapthon.serializer import Serializer
|
||||
from coapthon.utils import Tree, create_logging
|
||||
from coapthon.utils import Tree
|
||||
|
||||
__author__ = 'Giacomo Tanganelli'
|
||||
|
||||
|
||||
if not os.path.isfile("logging.conf"):
|
||||
create_logging()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
|
||||
|
||||
|
||||
class CoAP(object):
|
||||
|
|
|
@ -219,8 +219,12 @@ class Serializer(object):
|
|||
fmt += "B"
|
||||
values.append(defines.PAYLOAD_MARKER)
|
||||
|
||||
fmt += str(len(bytes(payload, "utf-8"))) + "s"
|
||||
values.append(bytes(payload, "utf-8"))
|
||||
if isinstance(payload, bytes):
|
||||
fmt += str(len(payload)) + "s"
|
||||
values.append(payload)
|
||||
else:
|
||||
fmt += str(len(bytes(payload, "utf-8"))) + "s"
|
||||
values.append(bytes(payload, "utf-8"))
|
||||
# for b in str(payload):
|
||||
# fmt += "c"
|
||||
# values.append(bytes(b, "utf-8"))
|
||||
|
|
|
@ -17,18 +17,13 @@ from coapthon.messages.response import Response
|
|||
from coapthon.resources.resource import Resource
|
||||
from coapthon.serializer import Serializer
|
||||
from coapthon.utils import Tree
|
||||
from coapthon.utils import create_logging
|
||||
import collections
|
||||
|
||||
|
||||
__author__ = 'Giacomo Tanganelli'
|
||||
|
||||
|
||||
if not os.path.isfile("logging.conf"):
|
||||
create_logging()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
|
||||
|
||||
|
||||
class CoAP(object):
|
||||
|
|
Loading…
Reference in a new issue