本文整理汇总了C++中PacketQueue::addPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::addPacket方法的具体用法?C++ PacketQueue::addPacket怎么用?C++ PacketQueue::addPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::addPacket方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
Connection con;
std::mutex zbSenderConditionVariableMutex;
std::condition_variable zbSenderConditionVariable;
PacketQueue zbSendQueue;
ZBSender * zbSender = new ZBSender(con.openPort(atoi(argv[1]), 9600), &zbSenderConditionVariableMutex, &zbSenderConditionVariable, &zbSendQueue);
boost::thread * zbSenderThread = new boost::thread(boost::ref(*zbSender));
std::vector<unsigned char> zigbeeAddress64bit{0X00, 0X13, 0XA2, 0X00, 0X40, 0X69, 0X73, 0X77};
std::vector<SensorType> sensors{TEMP, PRES, BAT};
for(int i = 0; i < 20; ++i)
{
LibelAddNodePacket * libelAddNodePacket = new LibelAddNodePacket(zigbeeAddress64bit, sensors);
zbSendQueue.addPacket(dynamic_cast<Packet *> (libelAddNodePacket));
zbSenderConditionVariableMutex.lock();
zbSenderConditionVariable.notify_all();
zbSenderConditionVariableMutex.unlock();
std::cout << "packet sent" << std::endl;
sleep(5);
}
zbSenderThread->join();
delete zbSender;
delete zbSenderThread;
return 0;
}