本文整理汇总了C++中AJ_ErrPrintf函数的典型用法代码示例。如果您正苦于以下问题:C++ AJ_ErrPrintf函数的具体用法?C++ AJ_ErrPrintf怎么用?C++ AJ_ErrPrintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AJ_ErrPrintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AJ_Net_Connect
AJ_Status AJ_Net_Connect(AJ_NetSocket* netSock, uint16_t port, uint8_t addrType, const uint32_t* addr)
{
int ret;
IPAddress ip(*addr);
AJ_InfoPrintf(("AJ_Net_Connect(nexSock=0x%p, port=%d., addrType=%d., addr=0x%p)\n", netSock, port, addrType, addr));
AJ_InfoPrintf(("AJ_Net_Connect(): Connect to 0x%x:%u.\n", addr, port));;
ret = g_client.connect(ip, port);
#ifdef NOTDEF
Serial.print("Connecting to: ");
Serial.print(ip);
Serial.print(':');
Serial.println(port);
#endif
if (ret == -1) {
AJ_ErrPrintf(("AJ_Net_Connect(): connect() failed: %d: status=AJ_ERR_CONNECT\n", ret));
return AJ_ERR_CONNECT;
} else {
AJ_IOBufInit(&netSock->rx, rxData, sizeof(rxData), AJ_IO_BUF_RX, (void*)&g_client);
netSock->rx.recv = AJ_Net_Recv;
AJ_IOBufInit(&netSock->tx, txData, sizeof(txData), AJ_IO_BUF_TX, (void*)&g_client);
netSock->tx.send = AJ_Net_Send;
AJ_ErrPrintf(("AJ_Net_Connect(): connect() success: status=AJ_OK\n"));
return AJ_OK;
}
AJ_ErrPrintf(("AJ_Net_Connect(): connect() failed: %d: status=AJ_ERR_CONNECT\n", ret));
return AJ_ERR_CONNECT;
}
示例2: MatchProp
static AJ_Status MatchProp(const char* member, const char* prop, uint8_t op, const char** sig)
{
const char* encoding = member;
if (*encoding++ != '@') {
AJ_ErrPrintf(("MatchProp(): AJ_ERR_NO_MATCH\n"));
return AJ_ERR_NO_MATCH;
}
while (*prop) {
if (*encoding++ != *prop++) {
AJ_ErrPrintf(("MatchProp(): AJ_ERR_NO_MATCH\n"));
return AJ_ERR_NO_MATCH;
}
}
if ((op == AJ_PROP_GET) && (*encoding == WRITE_ONLY)) {
AJ_ErrPrintf(("MatchProp(): AJ_ERR_DISALLOWED\n"));
return AJ_ERR_DISALLOWED;
}
if ((op == AJ_PROP_SET) && (*encoding == READ_ONLY)) {
AJ_ErrPrintf(("MatchProp(): AJ_ERR_DISALLOWED\n"));
return AJ_ERR_DISALLOWED;
}
*sig = ++encoding;
return AJ_OK;
}
示例3: ExportIfNeeded
static AJ_Status ExportIfNeeded(const char* dev, int deviceId, const char* root)
{
int fd;
DIR* dir;
char buf[256];
snprintf(buf, sizeof(buf), "%s%s", root, dev);
dir = opendir(buf);
if (dir) {
closedir(dir);
return AJ_OK;
}
if (errno != ENOENT) {
AJ_ErrPrintf(("Failed opendir %d %s\n", errno, buf));
return AJ_ERR_INVALID;
}
/*
* Try to create the device entry
*/
snprintf(buf, sizeof(buf), "%s%s", root, "export");
fd = open(buf, O_WRONLY);
if (fd >= 0) {
size_t sz = snprintf(buf, sizeof(buf), "%d", deviceId);
write(fd, buf, sz + 1);
close(fd);
return AJ_OK;
} else {
AJ_ErrPrintf(("Failed to open %s\n", buf));
return AJ_ERR_INVALID;
}
}
示例4: AJ_ARDP_UDP_Send
static AJ_Status AJ_ARDP_UDP_Send(void* context, uint8_t* buf, size_t len, size_t* sent)
{
AJ_Status status = AJ_OK;
DWORD ret;
NetContext* ctx = (NetContext*) context;
WSAOVERLAPPED ov;
DWORD flags = 0;
WSABUF wsbuf;
memset(&ov, 0, sizeof(ov));
ov.hEvent = sendEvent;
wsbuf.len = len;
wsbuf.buf = buf;
AJ_InfoPrintf(("AJ_ARDP_UDP_Send(buf=0x%p, len=%lu)\n", buf, len));
ret = WSASend(ctx->udpSock, &wsbuf, 1, NULL, flags, &ov, NULL);
if (ret == SOCKET_ERROR) {
AJ_ErrPrintf(("AJ_ARDP_UDP_Send(): WSASend() failed. WSAGetLastError()=0x%x, status=AJ_ERR_WRITE\n", WSAGetLastError()));
*sent = 0;
return AJ_ERR_WRITE;
}
if (!WSAGetOverlappedResult(ctx->udpSock, &ov, sent, TRUE, &flags)) {
AJ_ErrPrintf(("AJ_ARDP_UDP_Send(): WSAGetOverlappedResult() failed. WSAGetLastError()=0x%x, status=AJ_ERR_WRITE\n", WSAGetLastError()));
return AJ_ERR_WRITE;
}
return status;
}
示例5: AJNS_Producer_CancelNotification
AJ_Status AJNS_Producer_CancelNotification(AJ_BusAttachment* busAttachment, uint32_t serialNum)
{
AJ_Status status;
uint16_t messageType = 0;
AJ_InfoPrintf(("In CancelNotificationBySerialNum\n"));
if (serialNum == 0) {
AJ_ErrPrintf(("Could not cancel Message - no message to cancel\n"));
return AJ_OK;
}
for (; messageType < AJNS_NUM_MESSAGE_TYPES; messageType++) {
if (lastSentNotifications[messageType].serialNum == serialNum) {
break;
}
}
if (messageType >= AJNS_NUM_MESSAGE_TYPES) {
AJ_ErrPrintf(("Could not find matching Message serial number - no message to cancel\n"));
return AJ_OK;
}
status = AJ_BusCancelSessionless(busAttachment, serialNum);
if (status != AJ_OK) {
AJ_ErrPrintf(("Failed to send cancelation\n"));
return status;
}
AJ_InfoPrintf(("***************** Message with Notification id %d and serialNum %u deleted successfully *****************\n", lastSentNotifications[messageType].notificationId, lastSentNotifications[messageType].serialNum));
lastSentNotifications[messageType].notificationId = 0;
lastSentNotifications[messageType].serialNum = 0;
return status;
}
示例6: AJNS_Producer_DeleteLastNotification
AJ_Status AJNS_Producer_DeleteLastNotification(AJ_BusAttachment* busAttachment, uint16_t messageType)
{
AJ_Status status;
uint32_t lastSentSerialNumber;
// AJ_InfoPrintf(("In DeleteLastNotification\n"));
if (messageType >= AJNS_NUM_MESSAGE_TYPES)
{
AJ_ErrPrintf(("Could not delete Notification - MessageType is not valid\n"));
return AJ_ERR_DISALLOWED;
}
lastSentSerialNumber = lastSentNotifications[messageType].serialNum;
if (lastSentSerialNumber == 0)
{
AJ_ErrPrintf(("Could not Delete Message - no message to delete\n"));
return AJ_OK;
}
status = AJ_BusCancelSessionless(busAttachment, lastSentSerialNumber);
if (status != AJ_OK)
{
AJ_ErrPrintf(("Could not Delete Message\n"));
return status;
}
// AJ_InfoPrintf(("***************** Message with Notification id %d and serialNum %u deleted successfully *****************\n", lastSentNotifications[messageType].notificationId, lastSentNotifications[messageType].serialNum));
lastSentNotifications[messageType].notificationId = 0;
lastSentNotifications[messageType].serialNum = 0;
return status;
}
示例7: CPS_StartService
AJ_Status CPS_StartService(AJ_BusAttachment* bus, const char* busAddress, uint32_t timeout, uint8_t connected)
{
AJ_Status status = AJ_OK;
while (TRUE) {
AJ_InfoPrintf(("Attempting to connect to bus '%s'\n", busAddress));
status = AJ_Connect(bus, busAddress, timeout);
if (status != AJ_OK) {
AJ_ErrPrintf(("Failed to connect to bus '%s', sleeping for %d seconds...\n", busAddress, CPSC_CONNECT_PAUSE / 1000));
AJ_Sleep(CPSC_CONNECT_PAUSE);
continue;
}
AJ_InfoPrintf(("Connected successfully\n"));
isBusConnected = TRUE;
status = AJ_BusSetSignalRule(bus, CPSAnnounceMatch, AJ_BUS_SIGNAL_ALLOW);
if (status != AJ_OK) {
AJ_ErrPrintf(("Could not set Announcement Interface AddMatch\n"));
return status;
}
break;
}
;
return status;
}
示例8: AJNS_Consumer_SendDismissRequest
AJ_Status AJNS_Consumer_SendDismissRequest(AJ_BusAttachment* busAttachment, uint16_t version, int32_t notificationId, const char* appId, const char* senderName, uint32_t sessionId)
{
AJ_Status status = AJ_OK;
if ((status == AJ_OK) && (sessionId != 0)) {
AJ_Message dismissMsg;
status = AJ_MarshalMethodCall(busAttachment, &dismissMsg, NOTIFICATION_PRODUCER_DISMISS_PROXY, senderName, sessionId, AJ_NO_FLAGS, AJ_CALL_TIMEOUT);
if (status != AJ_OK) {
AJ_ErrPrintf(("Could not marshal method call\n"));
return status;
}
status = AJ_MarshalArgs(&dismissMsg, "i", notificationId);
if (status != AJ_OK) {
AJ_ErrPrintf(("Could not marshal arguments\n"));
return status;
}
status = AJ_DeliverMsg(&dismissMsg);
if (status != AJ_OK) {
AJ_ErrPrintf(("Could not deliver message\n"));
return status;
}
AJ_CloseMsg(&dismissMsg);
}
return status;
}
示例9: AJ_Net_Connect
AJ_Status AJ_Net_Connect(AJ_BusAttachment* bus, const AJ_Service* service)
{
int ret;
IPAddress ip(service->ipv4);
if (!(service->addrTypes & AJ_ADDR_TCP4)) {
AJ_ErrPrintf(("AJ_Net_Connect(): only IPV4 TCP supported\n", ret));
return AJ_ERR_CONNECT;
}
AJ_InfoPrintf(("AJ_Net_Connect(bus=0x%p, addrType=%d.)\n", bus, service->addrTypes));
ret = g_client.connect(ip, service->ipv4port);
if (ret != 1) {
AJ_ErrPrintf(("AJ_Net_Connect(): connect() failed: %d: status=AJ_ERR_CONNECT\n", ret));
return AJ_ERR_CONNECT;
} else {
AJ_IOBufInit(&bus->sock.rx, rxData, sizeof(rxData), AJ_IO_BUF_RX, (void*)&g_client);
bus->sock.rx.recv = AJ_Net_Recv;
AJ_IOBufInit(&bus->sock.tx, txData, sizeof(txData), AJ_IO_BUF_TX, (void*)&g_client);
bus->sock.tx.send = AJ_Net_Send;
AJ_ErrPrintf(("AJ_Net_Connect(): connect() success: status=AJ_OK\n"));
return AJ_OK;
}
AJ_ErrPrintf(("AJ_Net_Connect(): connect() failed: %d: status=AJ_ERR_CONNECT\n", ret));
return AJ_ERR_CONNECT;
}
示例10: OpenSimIO
static void OpenSimIO()
{
pthread_attr_t attr;
struct sockaddr_un sa;
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
memcpy(sa.sun_path, gui_server, sizeof(gui_server));
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock >= 0) {
pthread_t threadId;
int ret = connect(sock, (struct sockaddr*)&sa, sizeof(sa));
if (ret == -1) {
AJ_ErrPrintf(("Failed to connect to I/O gui server\n"));
close(sock);
sock = -1;
}
/*
* Create thread to handle reads
*/
pthread_attr_init(&attr);
ret = pthread_create(&threadId, NULL, SockRead, NULL);
if (ret) {
AJ_ErrPrintf(("Failed to create read thread\n"));
close(sock);
sock = -1;
} else {
pthread_detach(threadId);
pthread_cond_init(&cond, NULL);
pthread_mutex_init(&mutex, NULL);
}
}
}
示例11: AJ_ARDP_UDP_Recv
static AJ_Status AJ_ARDP_UDP_Recv(void* context, uint8_t** data, uint32_t* recved, uint32_t timeout)
{
NetContext* ctx = (NetContext*) context;
DWORD ret = SOCKET_ERROR;
WSAEVENT events[2];
DWORD flags = 0;
static uint8_t buffer[UDP_SEGBMAX];
*data = NULL;
if (wsaOverlapped.hEvent == INVALID_HANDLE_VALUE) {
wsbuf.len = sizeof(buffer);
wsbuf.buf = buffer;
memset(&wsaOverlapped, 0, sizeof(WSAOVERLAPPED));
wsaOverlapped.hEvent = recvEvent;
ret = WSARecvFrom(ctx->udpSock, &wsbuf, 1, NULL, &flags, NULL, NULL, &wsaOverlapped, NULL);
if ((ret == SOCKET_ERROR) && (WSAGetLastError() != WSA_IO_PENDING)) {
AJ_ErrPrintf(("WSARecvFrom(): failed WSAGetLastError()=%d\n", WSAGetLastError()));
return AJ_ERR_READ;
}
}
events[0] = wsaOverlapped.hEvent;
events[1] = interruptEvent;
ret = WSAWaitForMultipleEvents(2, events, FALSE, timeout, TRUE);
switch (ret) {
case WSA_WAIT_EVENT_0:
flags = 0;
if (WSAGetOverlappedResult(ctx->udpSock, &wsaOverlapped, recved, TRUE, &flags)) {
WSAResetEvent(wsaOverlapped.hEvent);
wsaOverlapped.hEvent = INVALID_HANDLE_VALUE;
*data = buffer;
return AJ_OK;
} else {
AJ_ErrPrintf(("AJ_ARDP_UDP_Recv(): WSAGetOverlappedResult error; WSAGetLastError()=%d\n", WSAGetLastError()));
return AJ_ERR_READ;
}
break;
case WSA_WAIT_EVENT_0 + 1:
WSAResetEvent(interruptEvent);
return AJ_ERR_INTERRUPTED;
case WSA_WAIT_TIMEOUT:
return AJ_ERR_TIMEOUT;
break;
default:
AJ_ErrPrintf(("AJ_ARDP_UDP_Recv(): WSAWaitForMultipleEvents error; WSAGetLastError()=%d\n", WSAGetLastError()));
return AJ_ERR_READ;
}
}
示例12: AJNS_Producer_ConnectedHandler
AJ_Status AJNS_Producer_ConnectedHandler(AJ_BusAttachment* busAttachment)
{
AJ_Status status;
AJ_SessionOpts sessionOpts = {
AJ_SESSION_TRAFFIC_MESSAGES,
AJ_SESSION_PROXIMITY_ANY,
AJ_TRANSPORT_ANY,
FALSE
};
uint8_t serviceStarted;
AJ_Message msg;
status = AJ_BusBindSessionPort(busAttachment, AJNS_NotificationProducerPort, &sessionOpts, 0);
if (status != AJ_OK) {
AJ_ErrPrintf(("Failed to send bind session port message\n"));
}
serviceStarted = FALSE;
while (!serviceStarted && (status == AJ_OK)) {
status = AJ_UnmarshalMsg(busAttachment, &msg, AJ_UNMARSHAL_TIMEOUT);
if (status == AJ_ERR_NO_MATCH) {
status = AJ_OK;
continue;
} else if (status != AJ_OK) {
break;
}
switch (msg.msgId) {
case AJ_REPLY_ID(AJ_METHOD_BIND_SESSION_PORT):
if (msg.hdr->msgType == AJ_MSG_ERROR) {
status = AJ_ERR_FAILURE;
} else {
serviceStarted = TRUE;
}
break;
default:
/*
* Pass to the built-in bus message handlers
*/
status = AJ_BusHandleBusMessage(&msg);
break;
}
AJ_CloseMsg(&msg);
}
if (status != AJ_OK) {
AJ_ErrPrintf(("AllJoyn disconnect bus status=%d\n", status));
status = AJ_ERR_READ;
}
return status;
}
示例13: AJ_BusLinkStateProc
AJ_Status AJ_BusLinkStateProc(AJ_BusAttachment* bus)
{
AJ_Status status = AJ_OK;
if (bus->isProbeRequired && busLinkTimeout)
{
if (!busLinkWatcher.linkTimerInited)
{
busLinkWatcher.linkTimerInited = TRUE;
AJ_InitTimer(&(busLinkWatcher.linkTimer));
}
else
{
uint32_t eclipse = AJ_GetElapsedTime(&(busLinkWatcher.linkTimer), TRUE);
if (eclipse >= busLinkTimeout)
{
if (!busLinkWatcher.pingTimerInited)
{
busLinkWatcher.pingTimerInited = TRUE;
AJ_InitTimer(&(busLinkWatcher.pingTimer));
if (AJ_OK != AJ_SendLinkProbeReq(bus))
{
AJ_ErrPrintf(("AJ_BusLinkStateProc(): AJ_SendLinkProbeReq() failure"));
}
}
else
{
eclipse = AJ_GetElapsedTime(&(busLinkWatcher.pingTimer), TRUE);
if (eclipse >= AJ_BUS_LINK_PING_TIMEOUT)
{
if (++busLinkWatcher.numOfPingTimedOut < AJ_MAX_LINK_PING_PACKETS)
{
AJ_InitTimer(&(busLinkWatcher.pingTimer));
if (AJ_OK != AJ_SendLinkProbeReq(bus))
{
AJ_ErrPrintf(("AJ_BusLinkStateProc(): AJ_SendLinkProbeReq() failure"));
}
}
else
{
AJ_ErrPrintf(("AJ_BusLinkStateProc(): AJ_ERR_LINK_TIMEOUT"));
status = AJ_ERR_LINK_TIMEOUT;
// stop sending probe messages until next link timeout event
memset(&busLinkWatcher, 0, sizeof(AJ_BusLinkWatcher));
}
}
}
}
}
}
return status;
}
示例14: AJ_Decrypt_CCM
/*
* Implements AES-CCM (Counter with CBC-MAC) decryption as described in RFC 3610
*/
AJ_Status AJ_Decrypt_CCM(const uint8_t* key,
uint8_t* msg,
uint32_t msgLen,
uint32_t hdrLen,
uint8_t tagLen,
const uint8_t* nonce,
uint32_t nLen)
{
AJ_Status status = AJ_OK;
CCM_Context* context;
if (!(context = InitCCMContext(nonce, nLen, hdrLen, msgLen, tagLen))) {
AJ_ErrPrintf(("AJ_Decrypt_CCM(): AJ_ERR_RESOURCES\n"));
return AJ_ERR_RESOURCES;
}
/*
* Do any platform specific operations to enable AES
*/
AJ_AES_Enable(key);
/*
* Decrypt the authentication field
*/
AJ_AES_CTR_128(key, msg + msgLen, msg + msgLen, tagLen, context->ivec.data);
/*
* Decrypt message.
*/
if (msgLen != hdrLen) {
AJ_AES_CTR_128(key, msg + hdrLen, msg + hdrLen, msgLen - hdrLen, context->ivec.data);
}
/*
* Compute and verify the authentication tag T.
*/
Compute_CCM_AuthTag(key, context, msg, msgLen - hdrLen, hdrLen);
/*
* Balance the enable call above
*/
AJ_AES_Disable();
if (AJ_Crypto_Compare(context->T.data, msg + msgLen, tagLen) != 0) {
/*
* Authentication failed Clear the decrypted data
*/
memset(msg, 0, msgLen + tagLen);
AJ_ErrPrintf(("AJ_Decrypt_CCM(): AJ_ERR_SECURITY\n"));
status = AJ_ERR_SECURITY;
}
/*
* Done with the context
*/
AJ_Free(context);
return status;
}
示例15: AJ_Net_Send
static AJ_Status AJ_Net_Send(AJ_IOBuffer* buf)
{
DWORD ret;
DWORD tx = AJ_IO_BUF_AVAIL(buf);
AJ_InfoPrintf(("AJ_Net_Send(buf=0x%p)\n", buf));
assert(buf->direction == AJ_IO_BUF_TX);
if (tx > 0) {
NetContext* ctx = (NetContext*) buf->context;
WSAOVERLAPPED ov;
DWORD flags = 0;
WSABUF wsbuf;
memset(&ov, 0, sizeof(ov));
ov.hEvent = sendEvent;
wsbuf.len = tx;
wsbuf.buf = buf->readPtr;
ret = WSASend(ctx->tcpSock, &wsbuf, 1, NULL, flags, &ov, NULL);
if (!WSAGetOverlappedResult(ctx->tcpSock, &ov, &tx, TRUE, &flags)) {
AJ_ErrPrintf(("AJ_Net_Send(): send() failed. WSAGetLastError()=0x%x, status=AJ_ERR_WRITE\n", WSAGetLastError()));
return AJ_ERR_WRITE;
}
buf->readPtr += tx;
}
if (AJ_IO_BUF_AVAIL(buf) == 0) {
AJ_IO_BUF_RESET(buf);
}
AJ_InfoPrintf(("AJ_Net_Send(): status=AJ_OK\n"));
return AJ_OK;
}