Connection Manager library for u-blox cellular modules. It manages the modem for keeping data connection always active.
Diff: CNUtil.cpp
- Revision:
- 0:86284a262735
diff -r 000000000000 -r 86284a262735 CNUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CNUtil.cpp Tue Jan 12 09:08:15 2016 +0000 @@ -0,0 +1,45 @@ +#include "CNUtil.h" +#include <stdarg.h> + +static int _debugLevel = 1; + +int getUtilDebugLevel(){ + return _debugLevel; +} +bool setUtilDebugLevel(int level){ +#ifdef CN_DEBUG + if ((_debugLevel >= -1) && (level >= -1) && + (_debugLevel <= 3) && (level <= 3)) { + _debugLevel = level; + return true; + } +#endif + return false; +} + +void debugPrint(int level, const char* color, const char* format, ...) +{ +#ifdef CN_DEBUG + if (_debugLevel >= level) + { + va_list args; + va_start (args, format); + if (color) ::printf(color); + ::vprintf(format, args); + if (color) ::printf(DEF); + va_end (args); + } +#endif +} + +void CNTimer::start() { + if (_counter++ == 0) Timer::start(); + else Timer::reset(); +} +bool CNTimer::isExpired(){ + if (Timer::read_ms() > _timeout) { + Timer::reset(); + return true; + } + else return false; +} \ No newline at end of file