import uthread import bluepy import locks import macho import iocp import localization mylog = log.Channel('GPS', 'socket') gai = socket.getaddrinfo @locks.SingletonCall def mygai(*args): return gai(*args) socket.getaddrinfo = mygai usingIOCP = iocp.UsingIOCP() if not usingIOCP: import stacklessio usesmartwakeup = bool(prefs.GetValue('useSmartWakeup', 0)) usependingcalls = bool(prefs.GetValue('usePendingCalls', 0)) usethreaddispatch = bool(prefs.GetValue('useThreadDispatch', 0)) stacklessio.ApplySettings({'useSmartWakeup': usesmartwakeup, 'usePendingCalls': usependingcalls, 'useThreadDispatch': usethreaddispatch}) blue.os.UseNewSleepMode(prefs.GetValue('useNewSleepMode', 0)) blue.os.CarbonIoFastWakeup(prefs.GetValue('carbonIoFastWakeup', 0)) stacklessioVersion = prefs.GetValue('stacklessioVersion', 0) stacklessioNobufProb = prefs.GetValue('stacklessioNobufProb', 0.0) stacklessioUseNoblock = prefs.GetValue('stacklessioUseNoblock', 1) stacklessioAllocChunkSize = prefs.GetValue('stacklessioAllocChunkSize', 1048576) socket.apply_settings({'version': stacklessioVersion,
import httpUtil import json import copy globals().update(service.consts) from timerstuff import ClockThis import iocp from service import ROLE_SERVICE, ROLE_REMOTESERVICE MACHONET_LOGMOVEMENT = 0 if '/disablePacketCompression' in blue.pyos.GetArg(): log.general.Log('Packet Compression: Disabled', log.LGINFO) MACHONET_COMPRESSION_DISABLED = True elif iocp.UsingCompression(): log.general.Log('Packet Compression: IOCP', log.LGINFO) if iocp.UsingIOCP(): import carbonio carbonio.setCompressionThreshold( prefs.GetValue('machoNet.minimumBytesToCompress', 200)) carbonio.setCompressionMinRatio( prefs.GetValue('packetCompressionMinimumRatio', 75)) carbonio.setCompressionLevel( prefs.GetValue('packetCompressionLevel', 6)) MACHONET_COMPRESSION_DISABLED = True else: log.general.Log( 'Could not turn on IOCP packet compression as IOCP is not enabled! Reverting to MachoNet compression...', log.LGERR) MACHONET_COMPRESSION_DISABLED = False else: log.general.Log('Packet Compression: MachoNet', log.LGINFO)