本文整理汇总了C++中irecv_client_t::received_callback方法的典型用法代码示例。如果您正苦于以下问题:C++ irecv_client_t::received_callback方法的具体用法?C++ irecv_client_t::received_callback怎么用?C++ irecv_client_t::received_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类irecv_client_t
的用法示例。
在下文中一共展示了irecv_client_t::received_callback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: irecv_receive
irecv_error_t irecv_receive(irecv_client_t client)
{
char buffer[BUFFER_SIZE];
int bytes = 0;
memset(buffer, '\0', BUFFER_SIZE);
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
while (irecv_bulk_transfer
(client, 0x81, (unsigned char *)buffer, BUFFER_SIZE, &bytes,
500) == 0) {
if (bytes > 0) {
if (client->received_callback != NULL) {
irecv_event_t event;
event.size = bytes;
event.data = buffer;
event.type = IRECV_RECEIVED;
if (client->received_callback(client, &event) !=
0) {
return IRECV_E_SUCCESS;
}
}
if (bytes < BUFFER_SIZE)
break;
} else
break;
}
return IRECV_E_SUCCESS;
}
示例2: irecv_receive
irecv_error_t irecv_receive(irecv_client_t client) {
unsigned char buffer[BUFFER_SIZE];
memset(buffer, '\0', BUFFER_SIZE);
if (client == NULL || client->handle == NULL) {
return IRECV_E_NO_DEVICE;
}
int bytes = 0;
while (libusb_bulk_transfer(client->handle, 0x81, buffer, BUFFER_SIZE, &bytes, 100) == 0) {
if (bytes > 0) {
if (client->received_callback != NULL) {
irecv_event_t event;
event.size = bytes;
event.data = buffer;
event.type = IRECV_RECEIVED;
if (client->received_callback(client, &event) != 0) {
return IRECV_E_SUCCESS;
}
}
} else break;
}
return IRECV_E_SUCCESS;
}