#include #include #include #define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8)) #define Sprintf(f, ...) ({ char* s; asprintf(&s, f, __VA_ARGS__); String r = s; free(s); r; }) #define SMacf(f) ({ auto nativeAddress = f.getNative(); Sprintf("%02x%02x%02x%02x%02x%02x", nativeAddress[5], nativeAddress[4], nativeAddress[3], nativeAddress[2], nativeAddress[1], nativeAddress[0]); }) #ifdef TX_DEFAULT static const int defaultTxPower = TX_DEFAULT; #else static const int defaultTxPower = -59; #endif static const uint16_t beaconUUID = 0xFEAA; static const uint16_t tileUUID = 0xFEED; static const uint16_t exposureUUID = 0xFD6F; static int median_of_3(int a, int b, int c) { int the_max = max(max(a, b), c); int the_min = min(min(a, b), c); // unnecessarily clever code int the_median = the_max ^ the_min ^ a ^ b ^ c; return (the_median); } static String getProximityUUIDString(BLEBeacon beacon) { std::string serviceData = beacon.getProximityUUID().toString().c_str(); int serviceDataLength = serviceData.length(); String returnedString = ""; int i = serviceDataLength; while (i > 0) { if (serviceData[i - 1] == '-') { i--; } char a = serviceData[i - 1]; char b = serviceData[i - 2]; returnedString += b; returnedString += a; i -= 2; } return returnedString; }