Indigresso Wiki

Open Source Stuff for DASH7

User Tools

Site Tools


opentag:otlib:ot_version_h

OT_version.h (OTlib)

OT_version.h contains constants and macros describing version & feature information for OpenTag – and more specifically OTlib. Of particular interest, OT_version.h defines a 32-bit bitfield that takes compiled-in configured settings from OT_config.h (actually via app_config.h), which gets Base64-converted and then stashed into the DASH7 Device Features ISF along with the OTlib version information.

OTlib/OT_version.h

Here is the code for OT_version.h. You may also refer to the doxygen code documentation.

#include "OT_config.h"

//BASE64 Converter
#define __B64_1(X)      (X+((25<=X)*65))
#define __B64_2(X)      ((X+((26<=X)&&(X<=51))*4) + (((26<=X)&&(X<=51))*__B64_1(X)))
#define __B64_3(X)      ((X-((52<=X)&&(X<=61))*4) + (((52<=X)&&(X<=61))*__B64_2(X)))
#define __B64_4(X)      ((X==62)*47 + ((X==62)*__B64_3(X)))
#define __B64_5(X)      (((X==63)*47) + ((X==63)*__B64_4(X)))
#define BASE64_EN(BYTE) ((ot_u8)__B64_5( (BYTE & 0x3F) ))


//OpenTag version code computation
#ifndef OT_VERSION_MAJOR
#   define OT_VERSION_MAJOR     0
#endif
#ifndef OT_BUILDTYPE
#   define OT_BUILDTYPE         'u'
#endif
#ifndef OT_BUILDID
#   define OT_BUILDID           0x0104
#endif
#ifndef OT_FEATURELIST
#   define OT_FEATURELIST       DEV_FEATURES_BITMAP
#endif


#define OT_BUILDCODE0   BASE64_EN((ot_u8)(OT_BUILDID>>10))
#define OT_BUILDCODE1   BASE64_EN((ot_u8)(OT_BUILDID>>4))
#define OT_BUILDCODE2   BASE64_EN((ot_u8)( (OT_BUILDID<<2)|(ot_u8)(OT_FEATURELIST>>30)) )
#define OT_BUILDCODE3   BASE64_EN((ot_u8)(OT_FEATURELIST>>24))
#define OT_BUILDCODE4   BASE64_EN((ot_u8)(OT_FEATURELIST>>18))
#define OT_BUILDCODE5   BASE64_EN((ot_u8)(OT_FEATURELIST>>12))
#define OT_BUILDCODE6   BASE64_EN((ot_u8)(OT_FEATURELIST>>6))
#define OT_BUILDCODE7   BASE64_EN((ot_u8)(OT_FEATURELIST>>0))



// Device Scheduler Settings
#if (OT_FEATURE(RTC) == ENABLED)
#   define OT_SUPPORTED_SCHEDULER   (((ot_u16)M2_FEATURE(RTCSLEEP) << 15)   | \
                                    ((ot_u16)M2_FEATURE(RTCHOLD) << 14)     | \
                                    ((ot_u16)M2_FEATURE(RTCBEACON) << 13))
#   if (M2_FEATURE(RTCSLEEP) == ENABLED) 
#       define OT_ACTIVE_SCHEDULER  0x8000
#   elif (M2_FEATURE(RTCHOLD) == ENABLED) 
#       define OT_ACTIVE_SCHEDULER  0x4000
#   elif (M2_FEATURE(RTCBEACON) == ENABLED) 
#       define OT_ACTIVE_SCHEDULER  0x2000
#   else
#       define OT_ACTIVE_SCHEDULER  0x0000
#   endif

#else
#   define OT_SUPPORTED_SCHEDULER   0x0000
#   define OT_ACTIVE_SCHEDULER      0x0000
#endif


// Device Class Settings
#define OT_SUPPORTED_CLASSES   (((ot_u16)M2_FEATURE(GATEWAY) << 11)         | \
                                ((ot_u16)M2_FEATURE(SUBCONTROLLER) << 10)   | \
                                ((ot_u16)M2_FEATURE(ENDPOINT) << 9)         | \
                                ((ot_u16)M2_FEATURE(BLINKER) << 11))
#if (M2_FEATURE(GATEWAY) == ENABLED) 
#   define OT_ACTIVE_CLASS      0x0800
#elif (M2_FEATURE(SUBCONTROLLER) == ENABLED) 
#   define OT_ACTIVE_CLASS      0x0400
#elif (M2_FEATURE(ENDPOINT) == ENABLED) 
#   define OT_ACTIVE_CLASS      0x0200
#elif (M2_FEATURE(BLINKER) == ENABLED) 
#   define OT_ACTIVE_CLASS      0x0100
#else
#   define OT_ACTIVE_CLASS      0x0000
#endif


// Device Datastreaming Settings
#if ((M2_FEATURE(M2DP) == ENABLED) && (M2_FEATURE(MULTIFRAME) == ENABLED))
#   define OT_SUPPORTED_DATASTREAM  0x0060
#elif (M2_FEATURE(M2DP) == ENABLED)
#   define OT_SUPPORTED_DATASTREAM  0x0040
#else
#   define OT_SUPPORTED_DATASTREAM  0x0000
#endif
#define OT_ACTIVE_DATASTREAM        OT_SUPPORTED_DATASTREAM


// Device FEC Settings
#define OT_SUPPORTED_FEC        (((ot_u16)M2_FEATURE(FECTX) << 5)     | \
                                 ((ot_u16)M2_FEATURE(FECRX) << 4))
#define OT_ACTIVE_FEC           OT_SUPPORTED_FEC


// Channel Usage Settings
#define OT_SUPPORTED_CHANS      (((ot_u16)M2_FEATURE(BLINK) << 3)     | \
                                 ((ot_u16)M2_FEATURE(TURBO) << 2)     | \
                                 ((ot_u16)M2_FEATURE(NORMAL) << 1)    | \
                                 ((ot_u16)M2_FEATURE(LEGACY)))
#define OT_ACTIVE_CHANS         OT_SUPPORTED_CHANS


// WRAPPER
#define OT_SUPPORTED_SETTINGS   (OT_SUPPORTED_SCHEDULER     | \
                                 OT_SUPPORTED_CLASSES       | \
                                 OT_SUPPORTED_DATASTREAM    | \
                                 OT_SUPPORTED_FEC           | \
                                 OT_SUPPORTED_CHANS)

#define OT_ACTIVE_SETTINGS      (OT_ACTIVE_SCHEDULER    | \
                                 OT_ACTIVE_CLASS        | \
                                 OT_ACTIVE_DATASTREAM   | \
                                 OT_ACTIVE_FEC          | \
                                 OT_ACTIVE_CHANS)
opentag/otlib/ot_version_h.txt · Last modified: 2012/03/26 21:23 by jpnorair