# Path: ZeroConfUtils.py
# def startZeroConfServer(portNumber):
#     ZeroConfServer(portNumber)
# 
# Path: Constants.py
# class OximeterStatus:
#     CONNECTED = 'connected'
#     PROBE_DISCONNECTED = 'Oximeter probe disconnected'
#     CABLE_DISCONNECTED = 'Serial cable disconnected'
# 
# class MotionReason:
#     NONE = "none"
#     BPM = "(heart rate is higher than threshold)"
#     CAMERA = "(motion detected on camera)"


from twisted.internet import reactor, stdio
from twisted.web import server, resource
from twisted.web.static import File
from twisted.protocols import basic
from datetime import datetime
from ZeroConfUtils import startZeroConfServer
from Constants import OximeterStatus, MotionReason
    from os import linesep as delimiter
import twisted.internet.error
import os
import logging
import json
#!/usr/bin/env python




def log(msg):
    tnow = datetime.now()
    logging.info('%s: %s' % (tnow.isoformat(), msg))

def setupLogging():
    logFormatter = logging.Formatter("%(message)s")
    rootLogger = logging.getLogger()
    rootLogger.setLevel(logging.DEBUG)

    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler)

MOTION_REASON_MAP = {
    0: MotionReason.NONE,
    1: MotionReason.CAMERA,
    2: MotionReason.BPM
}
OXIMETER_STATUS_MAP = {
    0: OximeterStatus.CONNECTED,

# Path: ZeroConfUtils.py
# def startZeroConfServer(portNumber):
#     ZeroConfServer(portNumber)
# 
# Path: Constants.py
# class OximeterStatus:
#     CONNECTED = 'connected'
#     PROBE_DISCONNECTED = 'Oximeter probe disconnected'
#     CABLE_DISCONNECTED = 'Serial cable disconnected'
# 
# class MotionReason:
#     NONE = "none"
#     BPM = "(heart rate is higher than threshold)"
#     CAMERA = "(motion detected on camera)"


# Path: TestSleepMonitor.py
from twisted.internet import reactor, stdio
from twisted.web import server, resource
from twisted.web.static import File
from twisted.protocols import basic
from datetime import datetime
from ZeroConfUtils import startZeroConfServer
from Constants import OximeterStatus, MotionReason
    from os import linesep as delimiter
import twisted.internet.error
import os
import logging
import json

#!/usr/bin/env python




def log(msg):
    tnow = datetime.now()
    logging.info('%s: %s' % (tnow.isoformat(), msg))

def setupLogging():
    logFormatter = logging.Formatter("%(message)s")
    rootLogger = logging.getLogger()
    rootLogger.setLevel(logging.DEBUG)

    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    rootLogger.addHandler(consoleHandler)

MOTION_REASON_MAP = {
    0: MotionReason.NONE,
    1: MotionReason.CAMERA,
    2: MotionReason.BPM
}
OXIMETER_STATUS_MAP = {
    0: OximeterStatus.CONNECTED,

    1: OximeterStatus.PROBE_DISCONNECTED,