Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/BLEManager/BLEGapServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,8 +1761,9 @@ std::vector<uint8_t> BLEGapServer::generateManufacturerData(uint16_t manufacture
// Convert serial number from ascii hex to binary (will be like BCD)
auto serialNoBytes = Raft::getBytesFromHexStr(serialNo.c_str(), MAX_SERIAL_NO_BYTES);

// Use the last N digits of the serial number
uint32_t maxSerialNoBytes = _bleConfig.advManufTotalByteLimit - manufacturerData.size();
// Use the last N digits of the serial number (none if the ID and fixed data already fill the limit)
uint32_t maxSerialNoBytes = _bleConfig.advManufTotalByteLimit > manufacturerData.size() ?
_bleConfig.advManufTotalByteLimit - manufacturerData.size() : 0;
uint32_t startPos = serialNoBytes.size() > maxSerialNoBytes ? serialNoBytes.size() - maxSerialNoBytes : 0;
manufacturerData.insert(manufacturerData.end(), serialNoBytes.begin() + startPos, serialNoBytes.begin() + serialNoBytes.size());
}
Expand Down
21 changes: 18 additions & 3 deletions components/BLEManager/BLEGattServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,33 @@ bool BLEGattServer::handleSubscription(struct ble_gap_event * pEvent, String& st
if (isResponseChar)
subscribed = (pEvent->subscribe.cur_notify != 0) || (pEvent->subscribe.cur_indicate != 0);
statusStr = "subscribe attr_handle=" + String(pEvent->subscribe.attr_handle) +
" reason=" + getHSErrorMsg(pEvent->subscribe.reason) +
" reason=" + getSubscribeReasonName(pEvent->subscribe.reason) +
" prevNotify=" + String(pEvent->subscribe.prev_notify) +
" curNotify=" + String(pEvent->subscribe.cur_notify) +
" prevInd=" + String(pEvent->subscribe.prev_indicate) +
" curInd=" + String(pEvent->subscribe.cur_indicate);
#ifdef DEBUG_RESP_SUBSCRIPTION
LOG_W(MODULE_PREFIX, "handleSubscription connHandle %d responseChar %s subscribed %s", pEvent->subscribe.conn_handle,
isResponseChar ? "YES" : "NO", subscribed ? "YES" : "NO");
LOG_W(MODULE_PREFIX, "handleSubscription connHandle %d responseChar %s subscribed %s %s", pEvent->subscribe.conn_handle,
isResponseChar ? "YES" : "NO", subscribed ? "YES" : "NO", statusStr.c_str());
#endif
return isResponseChar;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Name of the reason for a subscribe event (it isn't an error code)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const char* BLEGattServer::getSubscribeReasonName(uint8_t reason)
{
switch (reason)
{
case BLE_GAP_SUBSCRIBE_REASON_WRITE: return "write";
case BLE_GAP_SUBSCRIBE_REASON_TERM: return "term";
case BLE_GAP_SUBSCRIBE_REASON_RESTORE: return "restore";
default: return "unknown";
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get HS error message
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions components/BLEManager/BLEGattServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class BLEGattServer

// Get HS error message
static String getHSErrorMsg(int errorCode);
// Name of the reason for a subscribe event (CCCD written, connection ended, or restored when bonded)
static const char* getSubscribeReasonName(uint8_t reason);

// Outbound
BLEGattOutbound& getOutbound()
Expand Down
Loading