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.

CC2340R5: System ID middle value not equal to memory 0xFFFE value

Part Number: CC2340R5

SDK: simplelink_lowpower_f3_sdk_7_20_00_29

System ID in app_dev_info.c->DevInfo_start, as the code, it's consists with BLE address, set middle bytes with 0xFFFE value.

memcpy( &systemId[0], &devAddr[0], 3 ); // use 6 bytes of device address for 8 bytes of system ID value
memset( &systemId[3], 0xFFFE, 2 ); // set middle bytes to 0xFFFE
memcpy( &systemId[5], &devAddr[3], 3 ); // shift three bytes up

But both systemId[3] and systemId[4] equal 0xFE, not equal to value in 0xFFFE.

That's not make sense, can you explain details about this?

  • Hi,

    Thank you for reaching out.

    If I may, your usage of memset is not correct as the second parameter is cast as a 1-byte char.

    Your code should be:

    memcpy( &systemId[0], &devAddr[0], 3 ); // use 6 bytes of device address for 8 bytes of system ID value
    systemId[3] = 0xFF; // set middle bytes to 0xFFFE
    systemId[4] = 0xFE; // set middle bytes to 0xFFFE
    memcpy( &systemId[5], &devAddr[3], 3 ); // shift three bytes up

    I hope this will help,

    Best regards,

  • Hi, 

    Thanks for reply, the code is from sample project DataStream, not me write this.

    And from the code, seems it want to set middle value with value in memory address 0xFFFE, not set 0xFFFE as the value.

  • Hi,

    from the code, seems it want to set middle value with value in memory address 0xFFFE, not set 0xFFFE as the value.

    I am afraid this is not correct, please refer to the definition of the memset function I have shared in my previous answer.

    Assuming you want to copy the data from an address, you should used the memcpy function, but I don't think it make sense copying some random parts of the code into the systemId.

    the code is from sample project DataStream

    Thank you for telling me, I'll report the issue. This issue should be considered as minor.

    Best regards,

  • I am afraid this is not correct, please refer to the definition of the memset function I have shared in my previous answer.

    Assuming you want to copy the data from an address, you should used the memcpy function, but I don't think it make sense copying some random parts of the code into the systemId.

    Yes, the code memset( &systemId[3], 0xFFFE, 2 ); will set systemId[3] and systemId[4] to 0xFE, and through the comments, seems it's right on your reply

    memcpy( &systemId[0], &devAddr[0], 3 ); // use 6 bytes of device address for 8 bytes of system ID value
    systemId[3] = 0xFF; // set middle bytes to 0xFFFE
    systemId[4] = 0xFE; // set middle bytes to 0xFFFE
    memcpy( &systemId[5], &devAddr[3], 3 ); // shift three bytes up

    I need a definite answer and look forward to your reply.

    Best regards.

  • Hi,

    I need a definite answer and look forward to your reply.

    You should patch the code as following:

    memcpy( &systemId[0], &devAddr[0], 3 ); // use 6 bytes of device address for 8 bytes of system ID value
    systemId[3] = 0xFF; // set middle bytes to 0xFFFE
    systemId[4] = 0xFE; // set middle bytes to 0xFFFE
    memcpy( &systemId[5], &devAddr[3], 3 ); // shift three bytes up

    Regards,

  • You should patch the code as following:

    I will do it. And why use this value ?

  • Hi,

    This is an example of how you can set the systemId in the Bluetooth LE device Info profile. This is up to you to decide if this way of setting the systemId fits your use case or not.

    Regards,

  • Got it, Thank you!