How to perform a A2B network discovery using the SDK?

Document created by Rajesh Alwar on May 3, 2017
Version 1Show Document
  • View in full screen mode

The following snippet in anlzr-app.c example code provided to you does the discovery part. Discovery process is a part of setting up the stack. The app_stackSetup() function takes care of initialization, setup, polling for network events, etc. besides performing discovery.

 

            /* Create a network discovery request message */
            msg = a2b_msgAlloc(stackDcb->ctx, A2B_MSG_REQUEST,
                                A2B_MSGREQ_NET_DISCOVERY);
            if ( A2B_NULL == msg )
            {
                rc = APP_RC_FAILURE;
            }
            else
            {
                /* Attach the BDD information to the message */
                discReq = (a2b_NetDiscovery*)a2b_msgGetPayload(msg);
                discReq->req.bdd = &stackDcb->bdd;
                discReq->req.periphPkg = A2B_NULL;
                discReq->req.pkgLen = 0;
                a2b_msgSetUserData(msg, (a2b_Handle)stackDcb, A2B_NULL);
                status = a2b_msgRtrSendRequest(msg, A2B_NODEADDR_MASTER,
                                    app_onDiscoveryComplete);
                if ( A2B_FAILED(status) )
                {
                    rc = APP_RC_FAILURE;
                }
                /* The message router adds it's own reference to the
                 * submitted message.
                 */
                a2b_msgUnref(msg);
            }

 

Also, refer to the Doxygen documentation provided to you for more details.

Attachments

    Outcomes