本文整理汇总了C++中ConnectionManager::fillTransmitBuffers方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionManager::fillTransmitBuffers方法的具体用法?C++ ConnectionManager::fillTransmitBuffers怎么用?C++ ConnectionManager::fillTransmitBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::fillTransmitBuffers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataTransmittedCallback
void ConnectionManager::dataTransmittedCallback(ble_evt_t* bleEvent)
{
ConnectionManager* cm = ConnectionManager::getInstance();
//There are two types of events that trigger a dataTransmittedCallback
//A TX complete event frees a number of transmit buffers
//These are used for all connections
if(bleEvent->header.evt_id == BLE_EVT_TX_COMPLETE)
{
logt("CONN_DATA", "write_CMD complete (n=%d)", bleEvent->evt.common_evt.params.tx_complete.count);
//This connection has just been given back some transmit buffers
Connection* connection = cm->GetConnectionFromHandle(bleEvent->evt.common_evt.conn_handle);
connection->unreliableBuffersFree += bleEvent->evt.common_evt.params.tx_complete.count;
connection->sentUnreliable++;
//Next, we should continue sending packets if there are any
if(cm->GetPendingPackets()) cm->fillTransmitBuffers();
}
//The EVT_WRITE_RSP comes after a WRITE_REQ and notifies that a buffer
//for one specific connection has been cleared
else if (bleEvent->header.evt_id == BLE_GATTC_EVT_WRITE_RSP)
{
if(bleEvent->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS)
{
logt("ERROR", "GATT status problem %d %s", bleEvent->evt.gattc_evt.gatt_status, Logger::getGattStatusErrorString(bleEvent->evt.gattc_evt.gatt_status));
//TODO: Error handling, but there really shouldn't be an error....;-)
//FIXME: Handle possible gatt status codes
}
else
{
logt("CONN_DATA", "write_REQ complete");
Connection* connection = cm->GetConnectionFromHandle(bleEvent->evt.gattc_evt.conn_handle);
//Connection could have been disconneced
if(connection == NULL) return;
connection->sentReliable++;
//Check what type of Packet has just been sent
connPacketHeader* packetHeader = (connPacketHeader*)connection->lastSentPacket;
if(packetHeader->messageType == MESSAGE_TYPE_CLUSTER_INFO_UPDATE){
//Nothing to do
} else {
logt("CONN_DATA", "Header was type %d hasMoreParts %d", packetHeader->messageType, packetHeader->hasMoreParts);
//Check if the packet has more parts
if(packetHeader->hasMoreParts == 0){
//Packet was either not split at all or is completely sent
connection->packetSendPosition = 0;
//Check if this was the end of a handshake, if yes, mark handshake as completed
if(packetHeader->messageType == MESSAGE_TYPE_CLUSTER_ACK_2)
{
//Notify Node of handshakeDone
cm->node->HandshakeDoneHandler(connection, true);
}
//Discard the last packet because it was now successfully sent
connection->packetSendQueue->DiscardNext();
} else {
//Update packet send position if we have more data
connection->packetSendPosition += MAX_DATA_SIZE_PER_WRITE - SIZEOF_CONN_PACKET_SPLIT_HEADER;
}
}
connection->reliableBuffersFree += 1;
//Now we continue sending packets
if(cm->GetPendingPackets()) cm->fillTransmitBuffers();
}
}
}