aliro_stack.cpp
Independent implementation of the Nordic Aliro public API used by this app.
Overview
Independent implementation of the Nordic Aliro public API used by this app. Protocol constants and wire formats come from Aliro Specification 1.0.
depends on advertising_core.h
API
Fbool IsDigit(uint8_t value)
Returns true if value is an ASCII digit character (0x30–0x39).
ParseDecimalFint ParseDecimal(const uint8_t *value, size_t length)
Parses a decimal number from length bytes starting at value. Returns the parsed integer, or –1 if any byte is not an ASCII digit.
FromTimestamp · calls IsDigitFbool IsLeapYear(int year)
Returns true if year is a leap year.
IsValidDateFbool IsValidDate(int year, int month, int day)
Returns true if the given year, month, and day form a valid date. Accounts for leap years; rejects dates with year ≤ 0, month outside [1, 12], or day outside [1, days-in-month].
FromTimestamp · calls IsLeapYearFconst char *AliroError::ToString() const
Return a human-readable null-terminated string for this error code. Valid for all error enum values; returns "Unknown error" if the code is out of bounds.
FAliroError AliroError::FromInt(int ec)
Convert an integer error code to an AliroError object. Returns ALIRO_ERROR_UNKNOWN if the code is out of bounds (negative or >= ALIRO_ERROR_MAX); otherwise returns the corresponding error enum value.
Fstd::optional<Time> Time::FromTimestamp(const uint8_t *timestamp, size_t length)
Parses an RFC 3339 fixed-width timestamp in the form YYYY-MM-DDTHH:MM:SSZ (exactly 20 bytes). Returns a Time object on success; returns std::nullopt if the input is null, the wrong length, or contains an invalid date or time component.
IsValidDate, ParseDecimalFvoid BleTypes::AdvertisingServiceData::SetVersion(uint8_t version)
Sets the advertising version field (masked to kAdvertisingVersionMask bits).
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetNotification(Notification notification)
Sets the notification field (masked to kNotificationMask bits).
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetTxPowerLevel(TxPowerLevel powerLevelDbm)
Sets the TX power level in dBm.
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetTruncatedReaderGroupId(const uint8_t *readerGroupId)
Copies the first kTruncatedReaderGroupIdLength bytes of readerGroupId into mTruncatedReaderGroupId.
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetTruncatedReaderGroupSubId(const uint8_t *readerGroupSubId)
Copies the first kTruncatedReaderGroupSubIdLength bytes of readerGroupSubId into mTruncatedReaderGroupSubId.
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetDynamicTagExpiryTimestamp(BleExpiryTimestamp expiryTimestampUnix)
Encodes expiryTimestampUnix as a big-endian 32-bit integer into mDynamicTagExpiryTime.
GenerateAdvertisingDataFvoid BleTypes::AdvertisingServiceData::SetDynamicTag(const uint8_t *dynamicTag)
Copies dynamicTag (kWOZ_ALIRO_DYNAMIC_TAG_SIZE bytes) into mDynamicTag.
GenerateAdvertisingDataFAliroError AliroStack::Init()
Initializes the Aliro stack. Returns ALIRO_NO_ERROR on success.
Fconst char *AliroStack::GetLibraryVersion()
Returns the library version string.
Fconst ProtocolVersion *AliroStack::GetExpeditedStandardProtocolVersions(size_t &versionCount) const
Returns the array of protocol versions supported for expedited standard procedure, and sets versionCount to the array length.
Fuint8_t AliroStack::GetFeatures() const
Returns a bitmask of supported features: expedited fast phase, step-up phase, and BLE UWB, based on build configuration.
FAliroError AliroStack::GenerateAdvertisingData(BleTypes::AdvertisingServiceData &outData, const BleTypes::BleAddress &address, BleTypes::TxPowerLevel txPowerLevel, const Identifier &readerIdentifier, BleTypes::AdvertisingServiceData::Notification notification, BleTypes::BleExpiryTimestamp expirationTime)
Generates an Aliro BLE advertisement from the provided address, power level, reader identifier, notification state, and expiration timestamp. Validates inputs and derives the dynamic tag via encryption. Returns ALIRO_NO_ERROR on success; ALIRO_INVALID_ARGUMENT if txPowerLevel is outside [–100, 20] dBm or notification is out of range.
GetBleAdvertisingVersion, SetDynamicTag, SetDynamicTagExpiryTimestamp, SetNotification, SetTruncatedReaderGroupId, SetTruncatedReaderGroupSubId, SetTxPowerLevel, SetVersionFuint8_t AliroStack::GetBleAdvertisingVersion()
Returns the BLE advertising version supported by this stack.
GenerateAdvertisingDataFconst ProtocolVersion *AliroStack::GetBleUwbProtocolVersions(size_t &versionCount) const
Returns the array of protocol versions supported over BLE UWB, and sets versionCount to the array length.