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.

RTOS/CC2630: How do I change the current time in the destination device?

Part Number: CC2630
Other Parts Discussed in Thread: Z-STACK, CC2530

Tool/software: TI-RTOS

Hello!

I use the CC2630 as the end device and the СС2530 as a router and coordinator.

I use Z-Stack Home 1.2.2.

I want to change the current time in the end device and in router and coordinator.

To get the time, I use the code:

timestamp=Timestamp_get32();
Timestamp_getFreq(&freq);
seconds=(float)timestamp/freq.lo;

After reset, the timestamp is always 0.
1. How do I set (change) the timestamp to the current time?
2. I want to change the current time on the coordinator using UART, how can I do this? Is there a standard function?
3. I want to change the current time on the end device with the help of the coordinator. How can i do this?

  • Hi,

    The CC2530 Z-Stack has APIs to handle UTC time, check the document "OSAL API", section 12: OSAL Clock System. There is an MT interface for these API as well, search 3.8.1.19 SYS_SET_TIME in "Z-Stack Monitor and Test API". For the CC2630, the UTC time APIs are on the stack side, not the app side, so you can't easily use the same APIs to set the time, but after setting the time up on the Coordinator you could send the End Device a message with the current UTC time and you could then parse/store it in your application.
  • Thank you for your help!

    1. After I send a message to the destination device with the current RES-time, will I need to increase its value in the application independently?

    2. There is another problem. The problem is sending a message from the coordinator to the end device directly.

    I want to send a message from the coordinator to the end device. The polling time of the target device is more than 60 seconds. Changed the file znwk_config.h

    I use the following code in coordinator

    afAddrType_t dstAddr;
    dstAddr.addrMode = afAddr16Bit;
    dstAddr.addr.shortAddr = AssociatedDevList[0].shortAddr;
    dstAddr.endPoint = SAMPLETHERMOSTAT_ENDPOINT;
    uint16 Data_min = 0x61A8;

    zclWriteCmd_t *cmd = osal_mem_alloc( sizeof( zclWriteCmd_t ) + ( 1 * sizeof( zclWriteRec_t ) ) );
    cmd->numAttr = 1;
    cmd->attrList[0].attrID = ATTRID_MS_RELATIVE_HUMIDITY_MAX_MEASURED_VALUE; // FOR EXAMPLE
    cmd->attrList[0].dataType = ZCL_DATATYPE_UINT16; // data type
    cmd->attrList[0].attrData = (uint8*)&Data_min; // buffer

    zcl_SendWrite( SAMPLETHERMOSTAT_ENDPOINT, &dstAddr,
    ZCL_CLUSTER_ID_MS_RELATIVE_HUMIDITY,
    cmd, ZCL_FRAME_CLIENT_SERVER_DIR,
    TRUE, zclSampleThermostatSeqNum++ );

    osal_mem_free(cmd);

    When the target device calls data polling, the coordinator does not send a message.

    If you set the polling time of the end device to 5 seconds, the coordinator sends a message and the attribute is written to the end device.

    I changed the DNWK_INDIRECT_MSG_TIMEOUT parameter in the file f8wConfig.cfg by 100, 1000, 30000, 60000, but this did not help.

    How to make so that the coordinator stored the message for the finite device more long time?
  • 1. You don't need to increase it by yourself. Z-Stack would do it.
    2. Are you sure AssociatedDevList[0].shortAddr is the destination address of your end device?
  • 1. I can not understand how to transfer the current UTCtime to the end device? Is there a special command for this? What should I send from the coordinator to the end device?
    How in the CC2630 get UTCtime?
    2. Yes, I'm sure I'm currently using only 1 end device. Messages are sent from coordinator if the poll rate in end device is set equal to 1-5 sec.
  • Hi,

    You'd need to use a generic AF Data Request with a custom payload. You can send this from the coordinator to the end device and then parse the data in the application on the end device. You would only need to do it once for calibration purposes, then you can increment the time normally in the CC2630 application. On the CC2530, the OSAL UTC time APIs will automatically increment the time for you since this functionality is built in, but as mentioned before these APIs are not easily exposed on the CC2630 so you would need to do your own implementation of time keeping in the CC2630 application.

  • Hello! Thanks for the help!

    1. Could you give an example of using the AF Data Reques function to send time to the end device?

    2. How to make so that the coordinator stored the message for the end device more long time? Poll rate of the end device can be from 60 seconds.

  • 1. I suppose you can use time cluster to implement this. I suggest you to read section 3.12 Time in Zigbee cluster library specification.
    2. It's correct to use NWK_INDIRECT_MSG_TIMEOUT to control how long the message would be kept on parent node.
  • I understood why the message storage time does not increase. The parameter NWK_INDIRECT_MSG_TIMEOUT increases the time for indirect addressing. When dstAddr.addrMode = AddrNotPresent. And I use the Unicast addressing mode, When dstAddr.addrMode = afAddr16Bit.
    Now I have a few questions:
    1. Can I increase the message storage time for Unicast addressing mode, When dstAddr.addrMode = afAddr16Bit?
    2. I realized that in order to use indirect addressing it is necessary to bind the device. My devices without buttons. How can I bind the end devices to the coordinator?
    3. When the end device enters the network, it sends the command Device Announce to the coordinator. Can I get a short address of the end device?
  • 1. Actually, NWK_INDIRECT_MSG_TIMEOUT increases the time for both AddrNotPresent and afAddr16Bit.
    2. You can use API ZDP_BindReq to do binding from coordinator.
    3. Yes, device announcement contains short and IEEE address of joined device.
  • Thank you for your help! I solved my problems!
    1. I do not Rebuil all project, so the value of NWK_INDIRECT_MSG_TIMEOUT did not affect TransactionPersistenceTime in _NIB. Now it's ok!
  • Hello! I have another question!
    When I send the zcl_SendWrite command from the coordinator (CC2530) to the end device (CC2630), the attribute is written. All OK!
    When I send an attribute write command to the end device, I want to perform some actions in the application for the end device (CC2630). For example, write the received value of the attribute to the external EEPROM. How can i do this? Perhaps there is some callback function?
  • You can try to do it in zclParseInWriteCmd().
  • I did not understand where to use the zclParseInWriteCmd () function.
    My end device is CC2630.
    When I receive the zcl_SendWrite() command from the coordinator The application in CC2630 goes to the function Humid_TempSensor_processZStackMsgs(pMsg). Then goes to the function Humid_TempSensor_processAfIncomingMsgInd () (case zstackmsg_CmdIDs_AF_INCOMING_MSG_IND). Then incoming messages are passed to the ZCL message processor zcl_ProcessMessageMSG(&afMsg), first convert to a structure that ZCL can process. And it's all. Where should I use the zclParseInWriteCmd() function?
  • It seems that you are doing something different to what I used to do. If you already know the message would go to zcl_ProcessMessageMSG, I think you can do external flash write in it.
  • I'm using the SampleTemperatureSensor example.
    (Ti \ simplelink \ zstack_home_1_02_02a_44539 \ Projects \ zstack \ HomeAutomation \ SampleTemperatureSensor \ CC26xx).

    I do not know what message comes to the end device.

    I send zcl_SendWrite () or zcl_SendRead () command from the coordinator.

    In the end device in the main loop of the TempSensor_process () application, an event occurs in ICall_wait(ICALL_TIMEOUT_FOREVER) == ICALL_ERRNO_SUCCESS. The application proceeds to the TempSensor_processZStackMsgs (pMsg) function.
    In this function, switch->case ((pMsg->hdr.event==zstackmsg_CmdIDs_AF_INCOMING_MSG_IND)) goes to the function TempSensor_processAfIncomingMsgInd() . It is not clear exactly the message, ZCL_CMD_READ or ZCL_CMD_CREATE or other. The application then proceeds to the function zcl_ProcessMessageMSG(&afMsg).
    I can not understand which message was sent to the end device. I see only zstackmsg_CmdIDs_AF_INCOMING_MSG_IND.
    In the function zcl_ProcessMessageMSG() the response to the incoming message is already generated. And the response is sent to the coordinator.
  • If you set a breakpoint on in zclProcessInWriteCmd() and send write command to CC2630, does it hit the breakpoint?
  • Yes, it hit the breakpoint!
  • So, you can add your code in zclProcessInWriteCmd to check if it's the write command you want to save something to external flash.
  • Thank you!
    1. It is still possible in the function Humid_TempSensor_processAfIncomingMsgInd () using afIncomingMSGPacket_t afMsg to determine which message came from afMsg.cmd.Data = pInMsg->pPayload; I thought there were some standard processing tools or a callback function.

    2. Another question about ZCL_CLUSTER_ID_GEN_TIME. Do I need to put a special option in the project in the compiler options (for example, as ZCL_RED, ZCL_TEMPERATURE_MEASOREMENT) to use this Time cluster.
    Where can I find out all the available compile options?
  • 1. zclProcessInWriteCmd is the standard way to process write command. It's still possible to do it in Humid_TempSensor_processAfIncomingMsgInd. You can set breakpoint in zclProcessInWriteCmd and check call stack to see how zclProcessInWriteCmd works for your reference to do it in Humid_TempSensor_processAfIncomingMsgInd.
    2. No, you shouldn't need to define anything to use ZCL_CLUSTER_ID_GEN_TIME.