您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AJ_StatusText函数代码示例

51自学网 2021-06-01 19:34:22
  C++
这篇教程C++ AJ_StatusText函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中AJ_StatusText函数的典型用法代码示例。如果您正苦于以下问题:C++ AJ_StatusText函数的具体用法?C++ AJ_StatusText怎么用?C++ AJ_StatusText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了AJ_StatusText函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: AnonymousAuthAdvance

/** * Since the routing node expects any of its clients to use SASL with Anonymous * or PINX in order to connect, this method will send the necessary SASL * Anonymous exchange in order to connect.  PINX is no longer supported on the * Thin Client.  All thin clients will connect as untrusted clients to the * routing node. */static AJ_Status AnonymousAuthAdvance(AJ_IOBuffer* rxBuf, AJ_IOBuffer* txBuf){    AJ_Status status = AJ_OK;    AJ_GUID localGuid;    char buf[40];    /* initiate the SASL exchange with AUTH ANONYMOUS */    status = WriteLine(txBuf, "AUTH ANONYMOUS/n");    ResetRead(rxBuf);    if (status == AJ_OK) {        /* expect server to send back OK GUID */        status = ReadLine(rxBuf);        if (status == AJ_OK) {            if (memcmp(rxBuf->readPtr, "OK", 2) != 0) {                return AJ_ERR_ACCESS_ROUTING_NODE;            }        }    }    if (status == AJ_OK) {        status = WriteLine(txBuf, "INFORM_PROTO_VERSION 10/n");        ResetRead(rxBuf);    }    if (status == AJ_OK) {        /* expect server to send back INFORM_PROTO_VERSION version# */        status = ReadLine(rxBuf);    }    if (status == AJ_OK) {        if (memcmp(rxBuf->readPtr, "INFORM_PROTO_VERSION", strlen("INFORM_PROTO_VERSION")) != 0) {            status = AJ_ERR_ACCESS_ROUTING_NODE;        }    }    if (status == AJ_OK) {        routingProtoVersion = atoi((const char*)(rxBuf->readPtr + strlen("INFORM_PROTO_VERSION") + 1));        if (routingProtoVersion < AJ_GetMinProtoVersion()) {            AJ_InfoPrintf(("AnonymousAuthAdvance():: Found version %u but minimum %u required", routingProtoVersion, AJ_GetMinProtoVersion()));            status = AJ_ERR_OLD_VERSION;        }    }    if (status == AJ_OK) {        /* send BEGIN LocalGUID to server */        AJ_GetLocalGUID(&localGuid);        strcpy(buf, "BEGIN ");        status = AJ_GUID_ToString(&localGuid, buf + strlen(buf), 33);        strcat(buf, "/n");        status = WriteLine(txBuf, buf);        ResetRead(rxBuf);    }    if (status != AJ_OK) {        AJ_ErrPrintf(("AnonymousAuthAdvance(): status=%s/n", AJ_StatusText(status)));    }    return status;}
开发者ID:gwgoliath,项目名称:learnalljoyn,代码行数:67,


示例2: SendEvent

static AJ_Status SendEvent(AJ_BusAttachment* busAttachment, uint32_t eventId){    AJ_Status status = AJ_OK;    AJ_Message msg;    status = AJ_MarshalSignal(busAttachment, &msg, eventId, NULL, 0, AJ_FLAG_SESSIONLESS, 0);    if (status != AJ_OK) {        goto ErrorExit;    }    status = AJ_DeliverMsg(&msg);    if (status != AJ_OK) {        goto ErrorExit;    }    status = AJ_CloseMsg(&msg);    if (status != AJ_OK) {        goto ErrorExit;    }    AJ_AlwaysPrintf(("Event sent successfully/n"));    return status;ErrorExit:    AJ_AlwaysPrintf(("Event sending failed with status=%s/n", AJ_StatusText(status)));    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:25,


示例3: NativePWM

static int NativePWM(duk_context* ctx){    AJ_Status status;    double dutyCycle = duk_require_number(ctx, 0);    uint32_t freq = 0;    if (dutyCycle > 1.0 || dutyCycle < 0.0) {        duk_error(ctx, DUK_ERR_RANGE_ERROR, "Duty cycle must be in the range 0.0 to 1.0");    }    /*     * Frequency is optional. If not specified zero is passed into the target code and the default     * target PWM frequency is used.     */    if (!duk_is_undefined(ctx, 1)) {        freq = duk_require_int(ctx, 1);        if (freq == 0) {            duk_error(ctx, DUK_ERR_RANGE_ERROR, "Frequency cannot be zero Hz");        }    }    status = AJS_TargetIO_PinPWM(PinCtxPtr(ctx), dutyCycle, freq);    if (status != AJ_OK) {        if (status == AJ_ERR_RESOURCES) {            duk_error(ctx, DUK_ERR_RANGE_ERROR, "Too many PWM pins");        } else {            duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Error setting PWM %s", AJ_StatusText(status));        }    }    return 0;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:29,


示例4: NativeI2cTransfer

static int NativeI2cTransfer(duk_context* ctx){    AJ_Status status;    uint8_t addr = duk_require_int(ctx, 0);    uint8_t* txBuf = NULL;    uint8_t* rxBuf = NULL;    duk_size_t txLen = 0;    duk_size_t rxLen = 0;    uint8_t rxBytes = 0;    if (duk_is_undefined(ctx, 2)) {        duk_push_undefined(ctx);    } else {        rxLen = duk_require_uint(ctx, 2);        rxBuf = duk_push_dynamic_buffer(ctx, rxLen);    }    if (duk_is_null(ctx, 1)) {        duk_push_undefined(ctx);    } else {        txBuf = SerializeToBuffer(ctx, 1, &txLen);    }    status = AJS_TargetIO_I2cTransfer(PinCtxPtr(ctx), addr, txBuf, txLen, rxBuf, rxLen, &rxBytes);    if (status != AJ_OK) {        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "I2C transfer failed %s/n", AJ_StatusText(status));    }    duk_pop(ctx);    if (rxLen) {        duk_resize_buffer(ctx, -1, rxBytes);    }    return 1;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:31,


示例5: AJ_Net_RecvFrom

AJ_Status AJ_Net_RecvFrom(AJ_IOBuffer* buf, uint32_t len, uint32_t timeout){    AJ_InfoPrintf(("AJ_Net_RecvFrom(buf=0x%p, len=%d., timeout=%d.)/n", buf, len, timeout));    AJ_Status status = AJ_OK;    int ret;    uint32_t rx = AJ_IO_BUF_SPACE(buf);    unsigned long Recv_lastCall = millis();    AJ_InfoPrintf(("AJ_Net_RecvFrom(): len %d, rx %d, timeout %d/n", len, rx, timeout));    rx = min(rx, len);    while ((g_clientUDP.parsePacket() == 0) && (millis() - Recv_lastCall < timeout)) {        delay(10); // wait for data or timeout    }    AJ_InfoPrintf(("AJ_Net_RecvFrom(): millis %d, Last_call %d, timeout %d, Avail %d/n", millis(), Recv_lastCall, timeout, g_clientUDP.available()));    ret = g_clientUDP.read(buf->writePtr, rx);    AJ_InfoPrintf(("AJ_Net_RecvFrom(): read() returns %d, rx %d/n", ret, rx));    if (ret == -1) {        AJ_InfoPrintf(("AJ_Net_RecvFrom(): read() fails. status=AJ_ERR_READ/n"));        status = AJ_ERR_READ;    } else {        if (ret != -1) {            AJ_DumpBytes("AJ_Net_RecvFrom", buf->writePtr, ret);        }        buf->writePtr += ret;        AJ_InfoPrintf(("AJ_Net_RecvFrom(): status=AJ_OK/n"));        status = AJ_OK;    }    AJ_InfoPrintf(("AJ_Net_RecvFrom(): status=%s/n", AJ_StatusText(status)));    return status;}
开发者ID:durake,项目名称:core-ajtcl,代码行数:35,


示例6: AJApp_ConnectedHandler

static AJ_Status AJApp_ConnectedHandler(AJ_BusAttachment* busAttachment){    AJ_Status status = AJ_OK;    if (AJ_GetUniqueName(busAttachment)) {        if (currentServicesInitializationState == nextServicesInitializationState) {            switch (currentServicesInitializationState) {            case INIT_SERVICES:                status = AJSVC_ConnectedHandler(busAttachment);                if (status != AJ_OK) {                    goto ErrorExit;                }                currentServicesInitializationState = nextServicesInitializationState = INIT_FINISHED;                break;            case INIT_FINISHED:            default:                break;            }        }    }    return status;ErrorExit:    AJ_ErrPrintf(("Application ConnectedHandler returned an error %s/n", (AJ_StatusText(status))));    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:28,


示例7: AJOBS_ControllerAPI_StartSoftAPIfNeededOrConnect

AJ_Status AJOBS_ControllerAPI_StartSoftAPIfNeededOrConnect(AJOBS_Info* obInfo){    AJ_Status status = AJ_OK;    // Check if just started    if (bFirstStart) {        // Check if already Onboarded or in SoftAP mode        if (AJOBS_ControllerAPI_IsWiFiClient() || AJOBS_ControllerAPI_IsWiFiSoftAP()) {            AJ_InfoPrintf(("CONFIGURE_WIFI_UPON_START was set/n"));            return status;        }        bFirstStart = FALSE;        if (obInfo->state == AJOBS_STATE_CONFIGURED_RETRY) {            obInfo->state = AJOBS_STATE_CONFIGURED_VALIDATED;        }    }    while (1) {        status = AJOBS_ControllerAPI_GotoIdleWiFi(TRUE); // Go into IDLE mode, reset wifi and perfrom scan        if (status != AJ_OK) {            break;        }        // Check if require to switch into SoftAP mode.        if ((obInfo->state == AJOBS_STATE_NOT_CONFIGURED || obInfo->state == AJOBS_STATE_CONFIGURED_ERROR || obInfo->state == AJOBS_STATE_CONFIGURED_RETRY)) {            AJ_InfoPrintf(("Establishing SoftAP with ssid=%s%s auth=%s/n", obSettings->AJOBS_SoftAPSSID, (obSettings->AJOBS_SoftAPIsHidden ? " (hidden)" : ""), obSettings->AJOBS_SoftAPPassphrase == NULL ? "OPEN" : obSettings->AJOBS_SoftAPPassphrase));            if (obInfo->state == AJOBS_STATE_CONFIGURED_RETRY) {                AJ_InfoPrintf(("Retry timer activated/n"));                status = AJ_EnableSoftAP(obSettings->AJOBS_SoftAPSSID, obSettings->AJOBS_SoftAPIsHidden, obSettings->AJOBS_SoftAPPassphrase, obSettings->AJOBS_WAIT_BETWEEN_RETRIES);            } else {                status = AJ_EnableSoftAP(obSettings->AJOBS_SoftAPSSID, obSettings->AJOBS_SoftAPIsHidden, obSettings->AJOBS_SoftAPPassphrase, obSettings->AJOBS_WAIT_FOR_SOFTAP_CONNECTION);            }            if (status != AJ_OK) {                if (AJ_ERR_TIMEOUT == status) {                    //check for timer elapsed for retry                    if (obInfo->state == AJOBS_STATE_CONFIGURED_RETRY) {                        AJ_InfoPrintf(("Retry timer elapsed at %ums/n", obSettings->AJOBS_WAIT_BETWEEN_RETRIES));                        obInfo->state = AJOBS_STATE_CONFIGURED_VALIDATED;                        status = (*obWriteInfo)(obInfo);                        if (status == AJ_OK) {                            continue; // Loop back and connect in client mode                        }                    }                }                AJ_WarnPrintf(("Failed to establish SoftAP with status=%s/n", AJ_StatusText(status)));            }        } else { // Otherwise connect to given configuration and according to error code returned map to relevant onboarding state and set value for LastError and ConnectionResult.            status = DoConnectWifi(obInfo);            if (status == AJ_OK) {                if (obInfo->state == AJOBS_STATE_CONFIGURED_ERROR || obInfo->state == AJOBS_STATE_CONFIGURED_RETRY) {                    continue; // Loop back and establish SoftAP mode                }            } else {                AJ_WarnPrintf(("Failed to establish connection with current configuration status=%s/n", AJ_StatusText(status)));            }        }        break; // Either connected to (as client) or connected from (as SoftAP) a station    }    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:58,


示例8: AJApp_ConnectedHandler

static AJ_Status AJApp_ConnectedHandler(AJ_BusAttachment* busAttachment){    AJ_Status status = AJ_OK;    if (AJ_GetUniqueName(busAttachment)) {        if (currentServicesInitializationState == nextServicesInitializationState) {            switch (currentServicesInitializationState) {            case INIT_SERVICES:                status = AJSVC_ConnectedHandler(busAttachment);                if (status != AJ_OK) {                    goto ErrorExit;                }                currentServicesInitializationState = nextServicesInitializationState = INIT_SERVICES_PORT;                break;            case INIT_SERVICES_PORT:                status = AJ_BusBindSessionPort(busAttachment, AJ_ABOUT_SERVICE_PORT, NULL, 0);                if (status != AJ_OK) {                    goto ErrorExit;                }                nextServicesInitializationState = INIT_ADVERTISE_NAME;                break;            case INIT_ADVERTISE_NAME:                status = AJ_BusAdvertiseName(busAttachment, AJ_GetUniqueName(busAttachment), AJ_TRANSPORT_ANY, AJ_BUS_START_ADVERTISING, 0);                if (status != AJ_OK) {                    goto ErrorExit;                }                currentServicesInitializationState = nextServicesInitializationState = INIT_ABOUT;                break;            case INIT_ABOUT:                status = AJ_AboutInit(busAttachment, AJ_ABOUT_SERVICE_PORT);                if (status != AJ_OK) {                    goto ErrorExit;                }                currentServicesInitializationState = nextServicesInitializationState = INIT_CHECK_ANNOUNCE;                break;            case INIT_CHECK_ANNOUNCE:                status = AJ_AboutAnnounce(busAttachment);                if (status != AJ_OK) {                    goto ErrorExit;                }                break;            default:                break;            }        }    }    return status;ErrorExit:    AJ_ErrPrintf(("Application ConnectedHandler returned an error %s/n", (AJ_StatusText(status))));    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:58,


示例9: DismissActionCompleted

static void DismissActionCompleted(AJ_Status status, void* context){    AJ_AlwaysPrintf(("DismissActionCompleted() with status=%s/n", AJ_StatusText(status)));    if (!inputMode) {        nextAction = CONSUMER_ACTION_NOTHING;    }    processingAction = FALSE;    savedNotification.version = 0;    return;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:10,


示例10: AJServices_ConnectedHandler

AJ_Status AJServices_ConnectedHandler(AJ_BusAttachment* busAttachment){    AJ_BusSetPasswordCallback(busAttachment, PasswordCallback);    /* Configure timeout for the link to the Router bus */    AJ_SetBusLinkTimeout(busAttachment, 60);     // 60 seconds    AJ_Status status = AJ_OK;    status = AJ_About_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#ifdef CONFIG_SERVICE    status = AJCFG_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#endif#ifdef ONBOARDING_SERVICE    status = AJOBS_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#endif#ifdef NOTIFICATION_SERVICE_PRODUCER    status = AJNS_Producer_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#endif#ifdef CONTROLPANEL_SERVICE    status = AJCPS_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#endif#ifdef NOTIFICATION_SERVICE_CONSUMER    status = AJNS_Consumer_ConnectedHandler(busAttachment);    if (status != AJ_OK) {        goto ErrorExit;    }#endif    return status;ErrorExit:    AJ_AlwaysPrintf(("Service ConnectedHandler returned an error %s/n", (AJ_StatusText(status))));    return status;}
开发者ID:narcijie,项目名称:alljoyn-triton,代码行数:54,


示例11: AJOBS_EstablishWiFi

AJ_Status AJOBS_EstablishWiFi(){    AJ_Status status;    AJOBS_Info obInfo;    status = (*obReadInfo)(&obInfo);    AJ_InfoPrintf(("ReadInfo status: %s/n", AJ_StatusText(status)));    status = AJOBS_ControllerAPI_StartSoftAPIfNeededOrConnect(&obInfo);    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:12,


示例12: ReadLine

static AJ_Status ReadLine(AJ_IOBuffer* rxBuf){    /*     * All the authentication messages end in a CR/LF so read until we get a newline     */    AJ_Status status = AJ_OK;    while ((AJ_IO_BUF_AVAIL(rxBuf) == 0) || (*(rxBuf->writePtr - 1) != '/n')) {        status = rxBuf->recv(rxBuf, AJ_IO_BUF_SPACE(rxBuf), 3500);        if (status != AJ_OK) {            AJ_ErrPrintf(("ReadLine(): status=%s/n", AJ_StatusText(status)));            break;        }    }    return status;}
开发者ID:gwgoliath,项目名称:learnalljoyn,代码行数:15,


示例13: AJOBS_ConnectWiFiHandler

AJ_Status AJOBS_ConnectWiFiHandler(AJ_Message* msg){    AJ_Status status = AJ_OK;    AJ_InfoPrintf(("Handling ConnectWiFi request/n"));    AJOBS_Info obInfo;    status = AJOBS_GetInfo(&obInfo);    if (status != AJ_OK) {        return status;    }    AJ_InfoPrintf(("ReadInfo status: %s/n", AJ_StatusText(status)));    status = AJ_ERR_RESTART;     // Force disconnect of AJ and services and reconnection of WiFi on restart of message lopp    return status;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:15,


示例14: SendGetProp

AJ_Status SendGetProp(AJ_BusAttachment* bus, uint32_t sessionId, const char* serviceName){    AJ_Status status;    AJ_Message msg;    status = AJ_MarshalMethodCall(bus, &msg, PRX_GET_PROP, serviceName, sessionId, 0, METHOD_TIMEOUT);    if (status == AJ_OK) {        status = AJ_MarshalPropertyArgs(&msg, PRX_GET_INT);    }    if (status == AJ_OK) {        status = AJ_DeliverMsg(&msg);    } else {        AJ_AlwaysPrintf(("SendGetProp %s/n", AJ_StatusText(status)));    }    return status;}
开发者ID:gwgoliath,项目名称:learnalljoyn,代码行数:16,


示例15: AJOBS_SwitchToRetry

void AJOBS_SwitchToRetry(){    AJ_Status status = AJ_OK;    AJOBS_Info obInfo;    status = (*obReadInfo)(&obInfo);    if (status != AJ_OK) {        return;    }    obInfo.state = AJOBS_STATE_CONFIGURED_RETRY;    status = (*obWriteInfo)(&obInfo);    if (status != AJ_OK) {        return;    }    AJ_InfoPrintf(("SwitchToRetry status: %s/n", AJ_StatusText(status)));}
开发者ID:avernon,项目名称:asl_distribution,代码行数:17,


示例16: OnAboutMatch

static uint8_t OnAboutMatch(uint16_t version, uint16_t port, const char* peerName, const char* objPath){    AJ_Status status;    strncpy(serviceObjPath, objPath, sizeof(serviceObjPath));    serviceObjPath[sizeof(serviceObjPath) - 1] = 0;    strncpy(serviceName, peerName, sizeof(serviceName));    serviceName[sizeof(serviceName) - 1] = 0;    status = AJ_BusJoinSession(&bus, peerName, port, NULL);    if (status != AJ_OK) {        AJ_ErrPrintf(("JoinSession failed %s/n", AJ_StatusText(status)));    }    return TRUE;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:17,


示例17: AJ_Net_RecvFrom

AJ_Status AJ_Net_RecvFrom(AJ_IOBuffer* buf, uint32_t len, uint32_t timeout){    //AJ_InfoPrintf(("AJ_Net_RecvFrom(buf=0x%p, len=%d., timeout=%d.)/n", buf, len, timeout));    AJ_Status status = AJ_OK;    int ret;    uint32_t rx = AJ_IO_BUF_SPACE(buf);    unsigned long Recv_lastCall = millis();  //  printf("AJ_Net_RecvFrom(): len %d, rx %d, timeout %d/n", len, rx, timeout);	  //  rx = min(rx, len);   while ((sock_rx_state==0) && (millis() - Recv_lastCall < timeout))    {		//printf("millis() - Recv_lastCall = %d /n", (millis() - Recv_lastCall));		recv(rx_socket, udp_data_rx, MAIN_WIFI_M2M_BUFFER_SIZE, 0);		m2m_wifi_handle_events(NULL);		   }   ret=sock_rx_state;  // printf("AJ_Net_RecvFrom(): millis %d, Last_call %d, timeout %d, Avail %d/n", millis(), Recv_lastCall, timeout, g_clientUDP.available());    //ret = g_clientUDP.read(buf->writePtr, rx);	    //AJ_InfoPrintf(("AJ_Net_RecvFrom(): read() returns %d, rx %d/n", ret, rx));    if (ret == -1) 	{        printf("AJ_Net_RecvFrom(): read() fails. status=AJ_ERR_READ/n");        status = AJ_ERR_READ;    }	else	{        if (ret != -1) 		{            AJ_DumpBytes("AJ_Net_RecvFrom", buf->writePtr, ret);        }        buf->writePtr += ret;     //   printf("AJ_Net_RecvFrom(): status=AJ_OK/n");        status = AJ_OK;    }    printf("AJ_Net_RecvFrom(): status=%s/n", AJ_StatusText(status));    return /*sock_rx_state;*/status;}
开发者ID:marus-ka,项目名称:alljoyn_lsf_lamp,代码行数:44,


示例18: SetTriggerCallback

static int SetTriggerCallback(duk_context* ctx, int pinFunc, int debounce){    AJ_Status status;    int32_t trigId;    AJS_IO_PinTriggerCondition condition = (AJS_IO_PinTriggerCondition)duk_require_int(ctx, 0);    if (condition == AJS_IO_PIN_TRIGGER_DISABLE) {        /*         * For backwards compatibility         */        return ClearTriggerCallback(ctx, pinFunc, condition);    }    if (!duk_is_function(ctx, 1)) {        duk_error(ctx, DUK_ERR_TYPE_ERROR, "Trigger function required");    }    /*     * Enable the trigger     */    status = AJS_TargetIO_PinEnableTrigger(PinCtxPtr(ctx), pinFunc, condition, &trigId, debounce);    if (status != AJ_OK) {        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Error %s", AJ_StatusText(status));    }    duk_get_global_string(ctx, AJS_IOObjectName);    duk_get_prop_string(ctx, -1, AJS_HIDDEN_PROP("trigs"));    /*     * Set the callback function on the pin object     */    duk_push_this(ctx);    duk_dup(ctx, 1);    duk_put_prop_string(ctx, -2, "trigger");    /*     * Add the pin object to the triggers array.     */    duk_put_prop_index(ctx, -2, trigId);    duk_pop_2(ctx);    /*     * Leave pin object on the stack     */    return 1;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:40,


示例19: AJ_Main

int AJ_Main(void){    AJ_Status status = AJ_ERR_INVALID;    AJ_NVRAM_Init();    AJ_Printf("/nAllJoyn Release: %s/n/n", AJ_GetVersion());    /*     * The very first thing the test application does is to follow the trail of     * breadcrumbs, if available.     */    status = FollowTrailOfBreadcrumbs();    if (AJ_OK == status) {        AJ_Printf("PASS: Successfully read the known message from NVRAM and "                  "it is as expected. Done with the test./n");        return status;    } else {        AJ_Printf("INFO: No old remnants of a previous test run found./n");    }    /*     * The very last thing the test application does is to create the trail of     * breadcrumbs, to be compared upon start.     */    status = CreateTrailOfBreadcrumbs();    if (AJ_OK == status) {        AJ_Printf("INFO: Successfully wrote the known message to NVRAM./n");        AJ_Reboot(); /* Reboot the target, if available */    } else {        AJ_Printf("ERROR: CreateTrailOfBreadcrumbs failed: %s (code: %u)/n", AJ_StatusText(status), status);    }    AJ_Printf("INFO: Completed running the test. Exiting.../n");    return status;}
开发者ID:durake,项目名称:core-ajtcl,代码行数:39,


示例20: SendPing

AJ_Status SendPing(AJ_BusAttachment* bus, uint32_t sessionId, const char* serviceName, unsigned int num){    AJ_Status status;    AJ_Message msg;    /*     * Since the object path on the proxy object entry was not set in the proxy object table above     * it must be set before marshalling the method call.     */    status = AJ_SetProxyObjectPath(ProxyObjects, PRX_MY_PING, testObj);    if (status == AJ_OK) {        status = AJ_MarshalMethodCall(bus, &msg, PRX_MY_PING, serviceName, sessionId, 0, METHOD_TIMEOUT);    }    if (status == AJ_OK) {        status = AJ_MarshalArgs(&msg, "s", PingString);    }    if (status == AJ_OK) {        status = AJ_DeliverMsg(&msg);    } else {        AJ_AlwaysPrintf(("SendPing %s/n", AJ_StatusText(status)));    }    return status;}
开发者ID:gwgoliath,项目名称:learnalljoyn,代码行数:23,


示例21: AJ_StartService2

//.........这里部分代码省略.........                           uint32_t flags,                           const AJ_SessionOpts* opts                           ){    AJ_Status status;    AJ_Time timer;    uint8_t serviceStarted = FALSE;    uint8_t initial = TRUE;    AJ_InitTimer(&timer);    while (TRUE) {        if (AJ_GetElapsedTime(&timer, TRUE) > timeout) {            return AJ_ERR_TIMEOUT;        }        if (!initial || !connected) {            initial = FALSE;            AJ_InfoPrintf(("Attempting to connect to bus/n"));            status = AJ_Connect(bus, daemonName, CONNECT_TIMEOUT);            if (status != AJ_OK) {                AJ_WarnPrintf(("Failed to connect to bus sleeping for %d seconds/n", CONNECT_PAUSE / 1000));                AJ_Sleep(CONNECT_PAUSE);                continue;            }            AJ_InfoPrintf(("AllJoyn service connected to bus/n"));        }        /*         * Kick things off by binding a session port         */        status = AJ_BusBindSessionPort(bus, port, opts);        if (status == AJ_OK) {            break;        }        AJ_ErrPrintf(("Failed to send bind session port message/n"));        AJ_Disconnect(bus);    }    while (!serviceStarted && (status == AJ_OK)) {        AJ_Message msg;        AJ_GetElapsedTime(&timer, TRUE);        status = AJ_UnmarshalMsg(bus, &msg, UNMARSHAL_TIMEOUT);        /*         * TODO This is a temporary hack to work around buggy select imlpementations         */        if (status == AJ_ERR_TIMEOUT) {            if (AJ_GetElapsedTime(&timer, TRUE) < UNMARSHAL_TIMEOUT) {                AJ_WarnPrintf(("Spurious timeout error - continuing/n"));                status = AJ_OK;                continue;            }        }        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 {                status = AJ_BusRequestName(bus, name, flags);            }            break;        case AJ_REPLY_ID(AJ_METHOD_REQUEST_NAME):            if (msg.hdr->msgType == AJ_MSG_ERROR) {                status = AJ_ERR_FAILURE;            } else {                status = AJ_BusAdvertiseName(bus, name, AJ_TRANSPORT_ANY, AJ_BUS_START_ADVERTISING);            }            break;        case AJ_REPLY_ID(AJ_METHOD_ADVERTISE_NAME):            if (msg.hdr->msgType == AJ_MSG_ERROR) {                status = AJ_ERR_FAILURE;            } else {                serviceStarted = TRUE;                AJ_BusSetSignalRule2(bus, "NameOwnerChanged", "org.freedesktop.DBus", AJ_BUS_SIGNAL_ALLOW);            }            break;        default:            /*             * Pass to the built-in bus message handlers             */            status = AJ_BusHandleBusMessage(&msg);            break;        }        AJ_CloseMsg(&msg);    }    if (status != AJ_OK) {        AJ_WarnPrintf(("AllJoyn disconnect bus status=%s/n", AJ_StatusText(status)));        AJ_Disconnect(bus);    }    return status;}
开发者ID:reignme,项目名称:ajtcl,代码行数:101,


示例22: NativeIoAnalogOut

static int NativeIoAnalogOut(duk_context* ctx){    AJ_Status status;    int idx;    void* dacCtx;    uint32_t pin = GetPinId(ctx, 0, AJS_IO_FUNCTION_ANALOG_OUT);    status = AJS_TargetIO_DacOpen(pin, &dacCtx);    if (status == AJ_ERR_INVALID) {        duk_error(ctx, DUK_ERR_UNSUPPORTED_ERROR, "Analog input function not supported on pin%d", pin);    }    if (status != AJ_OK) {        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Failed to configure analog digital input pin: %s", AJ_StatusText(status));    }    idx = NewIOObject(ctx, dacCtx, AJS_IO_FUNCTION_ANALOG_OUT, NativeDacFinalizer);    /*     * Function to set the DAC     */    AJS_SetPropertyAccessors(ctx, idx, "value", NativeIoDacSetter, NULL);    /*     * Return the DAC object     */    return 1;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:24,


示例23: NativeIoDigitalIn

/* * Configures a pin as a digital input pin */static int NativeIoDigitalIn(duk_context* ctx){    AJ_Status status;    int idx;    void* pinCtx;    int config = -1;    uint32_t pin = GetPinId(ctx, 0, AJS_IO_FUNCTION_DIGITAL_IN);    if (duk_is_undefined(ctx, 1)) {        config = AJS_IO_PIN_PULL_UP;    } else if (duk_is_number(ctx, 1)) {        config = (AJS_IO_PinConfig)duk_get_int(ctx, 1);    }    if ((config != AJS_IO_PIN_OPEN_DRAIN) && (config != AJS_IO_PIN_PULL_UP) && (config != AJS_IO_PIN_PULL_DOWN)) {        duk_error(ctx, DUK_ERR_RANGE_ERROR, "Configuration must be pullUp, pullDown, or openDrain");    }    /*     * Target specific I/O pin initialization     */    status = AJS_TargetIO_PinOpen(pin, (AJS_IO_PinConfig)config, &pinCtx);    if (status != AJ_OK) {        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Failed to open digital input pin: %s", AJ_StatusText(status));    }    idx = NewIOObject(ctx, pinCtx, AJS_IO_FUNCTION_DIGITAL_IN, NativePinFinalizer);    /*     * Function to get the pin level     */    AJS_SetPropertyAccessors(ctx, idx, "level", NULL, NativeLevelGetter);    /*     * Function to set and clear a trigger     */    duk_push_c_lightfunc(ctx, NativePinSetTrigger, 3, 0, 0);    duk_put_prop_string(ctx, idx, "setTrigger");    duk_push_c_lightfunc(ctx, NativePinClearTrigger, 1, 0, 0);    duk_put_prop_string(ctx, idx, "clearTrigger");    /*     * Return the digital input pin object     */    return 1;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:43,


示例24: NativeIoDigitalOut

/* * Configures a pin as a digital output pin */static int NativeIoDigitalOut(duk_context* ctx){    AJ_Status status;    int idx;    void* pinCtx;    uint32_t pin = GetPinId(ctx, 0, AJS_IO_FUNCTION_DIGITAL_OUT);    /*     * Target specific I/O pin initialization     */    status = AJS_TargetIO_PinOpen(pin, AJS_IO_PIN_OUTPUT, &pinCtx);    if (status != AJ_OK) {        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Failed to configure digital output pin: %s", AJ_StatusText(status));    }    idx = NewIOObject(ctx, pinCtx, AJS_IO_FUNCTION_DIGITAL_OUT, NativePinFinalizer);    /*     * Functions to set/get the pin level     */    AJS_SetPropertyAccessors(ctx, idx, "level", NativeLevelSetter, NativeLevelGetter);    /*     * Check for and set initial value     */    if (duk_is_number(ctx, 1)) {        duk_dup(ctx, 1);        duk_put_prop_string(ctx, idx, "level");    }    /*     * Toggle function     */    duk_push_c_lightfunc(ctx, NativeTogglePin, 0, 0, 0);    duk_put_prop_string(ctx, idx, "toggle");    /*     * Only allow if the PWM functions is supported     */    if (AJS_TargetIO_GetInfo(pin)->functions & AJS_IO_FUNCTION_PWM) {        duk_push_c_lightfunc(ctx, NativePWM, 2, 0, 0);        duk_put_prop_string(ctx, idx, "pwm");    }    /*     * Return the digital output pin object     */    return 1;}
开发者ID:avernon,项目名称:asl_distribution,代码行数:46,


示例25: AJ_HandleIntrospectRequest

AJ_Status AJ_HandleIntrospectRequest(const AJ_Message* msg, AJ_Message* reply){    AJ_Status status = AJ_OK;    const AJ_Object* obj = objectLists[AJ_APP_ID_FLAG];    uint32_t children = 0;    AJ_Object parent;    WriteContext context;    /*     * Return an error if there are no local objects     */    if (!obj) {        return AJ_MarshalErrorMsg(msg, reply, AJ_ErrServiceUnknown);    }    /*     * Find out which object we are introspecting. There are two possibilities:     *     * - The request has a complete object path to one of the application objects.     * - The request has a path to a parent object of one or more application objects where the     *   parent itself is just a place-holder in the object hierarchy.     */    for (; obj->path != NULL; ++obj) {        if (strcmp(msg->objPath, obj->path) == 0) {            break;        }        if (ChildPath(msg->objPath, obj->path, NULL)) {            ++children;        }    }    /*     * If there was not a direct match but the requested node has children we create     * a temporary AJ_Object for the parent and introspect that object.     */    if ((obj->path == NULL) && children) {        parent.flags = 0;        parent.path = msg->objPath;        parent.interfaces = NULL;        obj = &parent;    }    /*     * Skip objects that are hidden or disabled     */    if (obj->path && !(obj->flags & (AJ_OBJ_FLAG_HIDDEN | AJ_OBJ_FLAG_DISABLED))) {        /*         * First pass computes the size of the XML string         */        context.len = 0;        status = GenXML(SizeXML, &context.len, obj, objectLists[1]);        if (status != AJ_OK) {            AJ_ErrPrintf(("AJ_HandleIntrospectRequest(): Failed to generate XML. status=%s", AJ_StatusText(status)));            return status;        }        /*         * Second pass marshals the XML         */        AJ_InfoPrintf(("AJ_HandleIntrospectRequest() %d bytes of XML/n", context.len));        AJ_MarshalReplyMsg(msg, reply);        /*         * Do a partial delivery         */        status = AJ_DeliverMsgPartial(reply, context.len + 5);        /*         * Marshal the string length         */        if (status == AJ_OK) {            status = AJ_MarshalRaw(reply, &context.len, 4);        }        if (status == AJ_OK) {            uint8_t nul = 0;            context.status = AJ_OK;            context.reply = reply;            GenXML(WriteXML, &context, obj, objectLists[1]);            status = context.status;            if (status == AJ_OK) {                /*                 * Marshal the terminating NUL                 */                status = AJ_MarshalRaw(reply, &nul, 1);            }        }    } else {        /*         * Return a ServiceUnknown error response         */        AJ_WarnPrintf(("AJ_HandleIntrospectRequest() NO MATCH for %s/n", msg->objPath));        AJ_MarshalErrorMsg(msg, reply, AJ_ErrServiceUnknown);    }    return status;}
开发者ID:jchuang1977,项目名称:alljoyn_14.02_thin_client,代码行数:89,


示例26: AJ_Main

//.........这里部分代码省略.........        case AJ_ERR_IO_BUFFER:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'An I/O buffer was invalid or in the wrong state'./n"));            break;        case AJ_ERR_READ:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'An error while reading data from the network'./n"));            break;        case AJ_ERR_WRITE:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'An error while writing data to the network'./n"));            break;        case AJ_ERR_TIMEOUT:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'A timeout occurred'./n"));            break;        case AJ_ERR_MARSHAL:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Marshaling failed due to badly constructed message argument'./n"));            break;        case AJ_ERR_UNMARSHAL:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Unmarshaling failed due to a corrupt or invalid message'./n"));            break;        case AJ_ERR_END_OF_DATA:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'No enough data'./n"));            break;        case AJ_ERR_RESOURCES:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Insufficient memory to perform the operation'./n"));            break;        case AJ_ERR_NO_MORE:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Attempt to unmarshal off the end of an array'./n"));            break;        case AJ_ERR_SECURITY:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Authentication or decryption failed'./n"));            break;        case AJ_ERR_CONNECT:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Network connect failed'./n"));            break;        case AJ_ERR_UNKNOWN:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'A unknown value'./n"));            break;        case AJ_ERR_NO_MATCH:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Something didn't match'./n"));            break;        case AJ_ERR_SIGNATURE:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'Signature is not what was expected'./n"));            break;        case AJ_ERR_DISALLOWED:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'An operations was not allowed'./n"));            break;        case AJ_ERR_FAILURE:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'A failure has occured'./n"));            break;        case AJ_ERR_RESTART:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'The OEM event loop must restart'./n"));            break;        case AJ_ERR_LINK_TIMEOUT:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'The bus link is inactive too long'./n"));            break;        case AJ_ERR_DRIVER:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned 'An error communicating with a lower-layer driver'./n"));            break;        case AJ_ERR_SESSION_LOST:            AJ_ErrPrintf(("The session was lost/n"));            break;        default:            AJ_ErrPrintf(("AJ_UnmarshalMsg() returned '%s'./n", AJ_StatusText(status)));            break;        }        /* Messages MUST be discarded to free resources. */        AJ_CloseMsg(&msg);        if (status == AJ_ERR_SESSION_LOST) {            AJ_AlwaysPrintf(("AllJoyn disconnect./n"));            AJ_Disconnect(&bus);            exit(0);        }    }    AJ_AlwaysPrintf(("signalConsumer_Client exiting with status 0x%04x./n", status));    return status;}
开发者ID:gwgoliath,项目名称:learnalljoyn,代码行数:101,


示例27: SetWidgetProp

static AJ_Status SetWidgetProp(AJ_Message* msg){    AJS_Widget* widget = NULL;    AJ_Message reply;    AJ_Status status;    uint32_t propId;    const char* vsig;    AJ_InfoPrintf(("SetWidgetProp %s/n", msg->objPath));    status = AJ_UnmarshalPropertyArgs(msg, &propId, &vsig);    /*     * Two levels of variant because Set always uses a variant and the property type for the widget     * is not known until runtime so is specified as a variant type in the property widget interface.     */    if (status == AJ_OK) {        status = AJ_UnmarshalVariant(msg, &vsig);    }    if (status == AJ_OK) {        status = AJ_UnmarshalVariant(msg, &vsig);    }    if (status == AJ_OK) {        widget = (AJS_Widget*)objectList[OBJ_INDEX(propId)].context;        /*         * Value is the only property that is writeable. Figure out how to unmarshal it.         */        switch (widget->property.wdt.signature[0]) {        case 'i':            status = AJ_UnmarshalArgs(msg, "i", &widget->property.val.i);            break;        case 'q':            status = AJ_UnmarshalArgs(msg, "q", &widget->property.val.q);            break;        case 'b':            status = AJ_UnmarshalArgs(msg, "b", &widget->property.val.b);            break;        case 'd':            status = AJ_UnmarshalArgs(msg, "d", &widget->property.val.d);            break;        case 's':            status = AJ_UnmarshalArgs(msg, "s", &widget->property.val.s);            break;        default:            {                AJ_Arg st;                uint16_t propertyType;                status = AJ_UnmarshalContainer(msg, &st, AJ_ARG_STRUCT);                if (status != AJ_OK) {                    break;                }                status = AJ_UnmarshalArgs(msg, "q", &propertyType);                if (status != AJ_OK) {                    break;                }                /*                 * For some reason the implementors of the control panel service used 0/1 to                 * distingsuish between date/time rather than 1/2. Incrementing the property type                 * fixes this oversight.                 */                if (++propertyType != widget->property.wdt.propertyType) {                    status = AJ_ERR_INVALID;                    break;                }                if (propertyType == TIME_VALUE_PROPERTY) {                    status = AJ_UnmarshalArgs(msg, "(qqq)", &widget->property.val.time.hour, &widget->property.val.time.minute, &widget->property.val.time.second);                } else {                    status = AJ_UnmarshalArgs(msg, "(qqq)", &widget->property.val.date.mDay, &widget->property.val.date.month, &widget->property.val.date.fullYear);                }                /*                 * Signal that the value has been changed                 */                AJS_CPS_SignalValueChanged(AJS_GetBusAttachment(), widget);                if (status == AJ_OK) {                    status = AJ_UnmarshalCloseContainer(msg, &st);                }            }            break;        }    } else {        return AJ_ERR_RESOURCES;    }    /*     * Need to make a clone of the message and close the original     */    msg = AJS_CloneAndCloseMessage(widget->dukCtx, msg);    if (!msg) {        return AJ_ERR_RESOURCES;    }    if (status == AJ_OK) {        /*         * Call JavaScript to report the value change         */        status =  AJS_CPS_OnValueChanged(widget);    } else {        AJ_ErrPrintf(("SetWidgetProp %s/n", AJ_StatusText(status)));//.........这里部分代码省略.........
开发者ID:dengcj0,项目名称:QCA4010,代码行数:101,


示例28: AJ_StartClient2

//.........这里部分代码省略.........         * Kick things off by finding the service names         */        status = AJ_BusFindAdvertisedName(bus, name, AJ_BUS_START_FINDING);        if (status == AJ_OK) {            break;        }        AJ_WarnPrintf(("FindAdvertisedName failed/n"));        AJ_Disconnect(bus);    }    *sessionId = 0;    while (!clientStarted && (status == AJ_OK)) {        AJ_Message msg;        if (AJ_GetElapsedTime(&timer, TRUE) > timeout) {            return AJ_ERR_TIMEOUT;        }        status = AJ_UnmarshalMsg(bus, &msg, UNMARSHAL_TIMEOUT);        /*         * TODO This is a temporary hack to work around buggy select imlpementations         */        AJ_InitTimer(&unmarshalTimer);        if (status == AJ_ERR_TIMEOUT && (AJ_GetElapsedTime(&unmarshalTimer, TRUE) < UNMARSHAL_TIMEOUT || !foundName)) {            /*             * Timeouts are expected until we find a name             */            status = AJ_OK;            continue;        }        if (status != AJ_OK) {            break;        }        switch (msg.msgId) {        case AJ_REPLY_ID(AJ_METHOD_FIND_NAME):        case AJ_REPLY_ID(AJ_METHOD_FIND_NAME_BY_TRANSPORT):            if (msg.hdr->msgType == AJ_MSG_ERROR) {                status = AJ_ERR_FAILURE;            } else {                uint32_t disposition;                AJ_UnmarshalArgs(&msg, "u", &disposition);                if ((disposition != AJ_FIND_NAME_STARTED) && (disposition != AJ_FIND_NAME_ALREADY)) {                    status = AJ_ERR_FAILURE;                }            }            break;        case AJ_SIGNAL_FOUND_ADV_NAME:            {                AJ_Arg arg;                AJ_UnmarshalArg(&msg, &arg);                AJ_InfoPrintf(("FoundAdvertisedName(%s)/n", arg.val.v_string));                foundName = TRUE;                status = AJ_BusJoinSession(bus, arg.val.v_string, port, opts);            }            break;        case AJ_REPLY_ID(AJ_METHOD_JOIN_SESSION):            {                uint32_t replyCode;                if (msg.hdr->msgType == AJ_MSG_ERROR) {                    status = AJ_ERR_FAILURE;                } else {                    status = AJ_UnmarshalArgs(&msg, "uu", &replyCode, sessionId);                    if (replyCode == AJ_JOINSESSION_REPLY_SUCCESS) {                        clientStarted = TRUE;                        AJ_BusSetSignalRule2(bus, "NameOwnerChanged", "org.freedesktop.DBus", AJ_BUS_SIGNAL_ALLOW);                    } else {                        status = AJ_ERR_FAILURE;                    }                }            }            break;        case AJ_SIGNAL_SESSION_LOST:            /*             * Force a disconnect             */            status = AJ_ERR_READ;            break;        default:            /*             * Pass to the built-in bus message handlers             */            status = AJ_BusHandleBusMessage(&msg);            break;        }        AJ_CloseMsg(&msg);    }    if (status != AJ_OK) {        AJ_WarnPrintf(("AllJoyn disconnect bus status=%s/n", AJ_StatusText(status)));        AJ_Disconnect(bus);    }    return status;}
开发者ID:reignme,项目名称:ajtcl,代码行数:101,


示例29: AJ_FindBusAndConnect

AJ_Status AJ_FindBusAndConnect(AJ_BusAttachment* bus, const char* serviceName, uint32_t timeout){    AJ_Status status;    AJ_Service service;#ifdef AJ_SERIAL_CONNECTION    AJ_Time start, now;    AJ_InitTimer(&start);#endif    AJ_InfoPrintf(("AJ_Connect(bus=0x%p, serviceName=/"%s/", timeout=%d.)/n", bus, serviceName, timeout));    /*     * Clear the bus struct     */    memset(bus, 0, sizeof(AJ_BusAttachment));    /*     * Clear stale name->GUID mappings     */    AJ_GUID_ClearNameMap();    /*     * Discover a daemon or service to connect to     */    if (!serviceName) {        serviceName = daemonService;    }#if AJ_CONNECT_LOCALHOST    service.ipv4port = 9955;#if HOST_IS_LITTLE_ENDIAN    service.ipv4 = 0x0100007F; // 127.0.0.1#endif#if HOST_IS_BIG_ENDIAN    service.ipv4 = 0x7f000001; // 127.0.0.1#endif    service.addrTypes = AJ_ADDR_IPV4;#elif defined ARDUINO    service.ipv4port = 9955;    service.ipv4 = 0x6501A8C0; // 192.168.1.101    service.addrTypes = AJ_ADDR_IPV4;    status = AJ_Discover(serviceName, &service, timeout);    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): AJ_Discover status=%s/n", AJ_StatusText(status)));        goto ExitConnect;    }#elif defined AJ_SERIAL_CONNECTION    // don't bother with discovery, we are connected to a daemon.    // however, take this opportunity to bring up the serial connection    status = AJ_Serial_Up();    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): AJ_Serial_Up status=%s/n", AJ_StatusText(status)));    }#else    status = AJ_Discover(serviceName, &service, timeout);    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): AJ_Discover status=%s/n", AJ_StatusText(status)));        goto ExitConnect;    }#endif    status = AJ_Net_Connect(&bus->sock, service.ipv4port, service.addrTypes & AJ_ADDR_IPV4, &service.ipv4);    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): AJ_Net_Connect status=%s/n", AJ_StatusText(status)));        goto ExitConnect;    }#ifdef AJ_SERIAL_CONNECTION    // run the state machine for long enough to (hopefully) do the SLAP handshake    do {        AJ_StateMachine();        AJ_InitTimer(&now);    } while (AJ_SerialLinkParams.linkState != AJ_LINK_ACTIVE && AJ_GetTimeDifference(&now, &start) < timeout);    if (AJ_SerialLinkParams.linkState != AJ_LINK_ACTIVE) {        AJ_InfoPrintf(("Failed to establish active SLAP connection in %u msec/n", timeout));        AJ_SerialShutdown();        return AJ_ERR_TIMEOUT;    }#endif    status = AJ_Authenticate(bus);    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): AJ_Authenticate status=%s/n", AJ_StatusText(status)));        goto ExitConnect;    }    // subscribe to the signal NameOwnerChanged and wait for the response    status = AJ_BusSetSignalRule(bus, "type='signal',member='NameOwnerChanged',interface='org.freedesktop.DBus'", AJ_BUS_SIGNAL_ALLOW);ExitConnect:    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Connect(): status=%s/n", AJ_StatusText(status)));        AJ_Disconnect(bus);    }    return status;}
开发者ID:CasyWang,项目名称:Triton,代码行数:96,


示例30: AJ_Authenticate

AJ_Status AJ_Authenticate(AJ_BusAttachment* bus){    AJ_Status status = AJ_OK;    AJ_SASL_Context sasl;    /*     * Send initial NUL byte     */    bus->sock.tx.writePtr[0] = 0;    bus->sock.tx.writePtr += 1;    status = bus->sock.tx.send(&bus->sock.tx);    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Authenticate(): status=%s/n", AJ_StatusText(status)));        goto ExitConnect;    }    AJ_SASL_InitContext(&sasl, mechList, AJ_AUTH_RESPONDER, busAuthPwdFunc, FALSE);    while (TRUE) {        status = AuthAdvance(&sasl, &bus->sock.rx, &bus->sock.tx);        if ((status != AJ_OK) || (sasl.state == AJ_SASL_FAILED)) {            break;        }        if (sasl.state == AJ_SASL_AUTHENTICATED) {            status = SendHello(bus);            break;        }    }    if (status == AJ_OK) {        AJ_Message helloResponse;        status = AJ_UnmarshalMsg(bus, &helloResponse, 5000);        if (status == AJ_OK) {            /*             * The only error we might get is a timeout             */            if (helloResponse.hdr->msgType == AJ_MSG_ERROR) {                status = AJ_ERR_TIMEOUT;            } else {                AJ_Arg arg;                status = AJ_UnmarshalArg(&helloResponse, &arg);                if (status == AJ_OK) {                    if (arg.len >= (sizeof(bus->uniqueName) - 1)) {                        AJ_ErrPrintf(("AJ_Authenticate(): AJ_ERR_RESOURCES/n"));                        status = AJ_ERR_RESOURCES;                    } else {                        memcpy(bus->uniqueName, arg.val.v_string, arg.len);                        bus->uniqueName[arg.len] = '/0';                    }                }            }            AJ_CloseMsg(&helloResponse);            // subscribe to the signal NameOwnerChanged and wait for the response            status = AJ_BusSetSignalRule(bus, "type='signal',member='NameOwnerChanged',interface='org.freedesktop.DBus'", AJ_BUS_SIGNAL_ALLOW);            if (status == AJ_OK) {                uint8_t found_reply = FALSE;                AJ_Message msg;                AJ_Time timer;                AJ_InitTimer(&timer);                while (found_reply == FALSE && AJ_GetElapsedTime(&timer, TRUE) < 3000) {                    status = AJ_UnmarshalMsg(bus, &msg, 3000);                    if (status == AJ_OK) {                        switch (msg.msgId) {                        case AJ_REPLY_ID(AJ_METHOD_ADD_MATCH):                            found_reply = TRUE;                            break;                        default:                            // ignore everything else                            AJ_BusHandleBusMessage(&msg);                            break;                        }                        AJ_CloseMsg(&msg);                    }                }            }        }    }ExitConnect:    if (status != AJ_OK) {        AJ_InfoPrintf(("AJ_Authenticate(): status=%s/n", AJ_StatusText(status)));    }    return status;}
开发者ID:CasyWang,项目名称:Triton,代码行数:87,



注:本文中的AJ_StatusText函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ AKLOGE函数代码示例
C++ AJ_InfoPrintf函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。