Connection Manager library for u-blox cellular modules. It manages the modem for keeping data connection always active.

Dependents:   C027_demo_ConnMan

CNUtil.cpp

Committer:
msinig
Date:
2016-01-12
Revision:
0:86284a262735

File content as of revision 0:86284a262735:

#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;
}