This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

eliminate the use of joystick for configuring coordinator and end device in the example program of TIMAC

Other Parts Discussed in Thread: TIMAC, MSP430F5438A, CC2520

Hai,

I am using TIMAC for WSN.i have use the sample example provided for data transmission between end device and coordinator.i am using msp430f5438a+cc2520 for the nodes.

in the example program we have to use the joystick to configure the nodes as end device and coordinator.

i want to eliminate the use of joystick in the TIMAC program.i want the configure the end devices and coordinator programmically.and the moment i dump the code  on the controller my program should run for TIMAC.

is it possible?

if yes please guide.

thank you

  • Hi Pratap, 

    I will try to give you few pointer which you could use to achieve the requirements:

    On the device which you want to always configure as the coordinator 

    In the function MSA_Init() at the end add the call to the function - which will start the device as a coordinator. 

    MSA_CoordinatorStartup();

    You can chose a more detailed approach for ex-, where you can first start an active scan to collect the beacons and for each MAC_MLME_BEACON_NOTIFY_IND you will check if the PANID of network around you is not the same as the one you are trying to select, etc. 

    Now, on the device which you want to always configure as the end device 

    In the function MSA_Init() at the end add the call to the function - which will start the network discovery 

    /* Start the device as a direct message device and beacon disabled*/
    if (!msa_IsStarted)
    {
    /* Decide if direct or indirect messaging is used */
    msa_IsDirectMsg = MSA_DIRECT_MSG_ENABLED;

    if (msa_IsDirectMsg)
    {
    /* Start the device as an DIRECT messaging device */
    if (msa_BeaconOrder != 15)
    MSA_ScanReq(MAC_SCAN_PASSIVE, MSA_MAC_BEACON_ORDER + 1);
    else
    MSA_ScanReq(MAC_SCAN_ACTIVE, 3);
    }
    else
    {
    /* Start the device as an INDIRECT messaging device and beacon disabled */
    /* Beacon network doesn't work with polling */
    if (!msa_IsStarted)
    {
    msa_IsDirectMsg = FALSE;
    MSA_ScanReq(MAC_SCAN_ACTIVE, 3);
    }
    }
    }

    And in case the coordinator was not started, to avoid this device becoming the coordinator (which the sample application would do) you would need to change the code at 

    ase MAC_MLME_SCAN_CNF:
    /* Check if there is any Coordinator out there */
    pData = (macCbackEvent_t *) pMsg;

    /* If there is no other on the channel or no other with sampleBeacon start as coordinator */
    if (((pData->scanCnf.resultListSize == 0) && (pData->scanCnf.hdr.status == MAC_NO_BEACON)) || (!msa_IsSampleBeacon))
    {
     // MSA_CoordinatorStartup();  --> Comment this line and you can try to start the network discovery again, etc
    }
    else if ((msa_IsSampleBeacon) && pData->scanCnf.hdr.status == MAC_SUCCESS)
    {
    /* Start the devive up as beacon enabled or not */
    MSA_DeviceStartup();

    /* Call Associate Req */
    MSA_AssociateReq();
    }
    break;

    Hope this helps. 

    Regards

  • Thank you Suyash Sir,

    The changes which you showed above is perfectly working to configure as coordinator and receiver.

    but i want to send the data from coordinator to end device or vice-verse the moment i configure the devices without using joystick.if i add the following code in the coordinator side will it work.

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    MSA_CoordinatorStartup();

    if (msa_IsStarted)
    {

    if (msa_State == MSA_IDLE_STATE)
    msa_State = MSA_SEND_STATE;
    else
    msa_State = MSA_IDLE_STATE;


    osal_start_timerEx(MSA_TaskId, MSA_SEND_EVENT, 100);
    }

    and on the receiver side the changes as you said above.

    thank you

  • thank you sir,

    i solved the problem

    i made changes in the function msa_init()

    case MAC_MLME_ASSOCIATE_CNF:
    /* Retrieve the message */
    pData = (macCbackEvent_t *) pMsg;

    if ((!msa_IsStarted) && (pData->associateCnf.hdr.status == MAC_SUCCESS))
    {
    msa_IsStarted = TRUE;

    /* Retrieve MAC_SHORT_ADDRESS */

    msa_DevShortAddr = pData->associateCnf.assocShortAddress;

    /* Setup MAC_SHORT_ADDRESS - obtained from Association */
    MAC_MlmeSetReq(MAC_SHORT_ADDRESS, &msa_DevShortAddr);





    /* Start sending message */
    if (msa_IsStarted)
    {
    /* Set App's state to SEND or IDLE */
    if (msa_State == MSA_IDLE_STATE)
    msa_State = MSA_SEND_STATE;
    else
    msa_State = MSA_IDLE_STATE;

    /* Send Event to the App to carry out the changes */
    osal_start_timerEx(MSA_TaskId, MSA_SEND_EVENT, 100);
    }