This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

otThreadSetMasterKey() usage

This function succeeds only when Thread protocols are disabled. my question is: if the Thread protocols are enable,what should I do to disable them  ,now what I do is:

"otThreadSetEnabled(otIns,false);
errornum = otThreadSetMasterKey(otIns,otMasKey);
otThreadSetEnabled(otIns,true);"

but it doesn't work , I need help 

   thanks 

Parents Reply Children
  • Yes, the SDK is "nRF5_SDK_for_Thread_and_Zigbee_v4.1.0" , the examples is "examples\multiprotocol\ble_thread\ble_thread_dyn_template"  and the define of otMasKey is:

    otMasterKey *otMasKey;

    otMasKey->m8[0] = 0xff;
    otMasKey->m8[1] = 0xee;
    otMasKey->m8[2] = 0xaa;
    otMasKey->m8[3] = 0xbb;
    otMasKey->m8[4] = 0xcc;
    otMasKey->m8[5] = 0x11;
    otMasKey->m8[6] = 0x00;
    otMasKey->m8[7] = 0x22;
    otMasKey->m8[8] = 0x33;
    otMasKey->m8[9] = 0x44;
    otMasKey->m8[10] = 0x55;
    otMasKey->m8[11] = 0x66;
    otMasKey->m8[12] = 0x77;
    otMasKey->m8[13] = 0x88;
    otMasKey->m8[14] = 0x99;
    otMasKey->m8[15] = 0xdd;

    I think there is no problem with this definition, I have modified this example when ble received some special string, it go into:

    "otThreadSetEnabled(otIns,false);
    errornum = otThreadSetMasterKey(otIns,otMasKey);
    otThreadSetEnabled(otIns,true);"

    then came the question above, what problems can you find about the above ?

     thanks

  • You are creating a pointer to the otMasterKey object, but you do not create the object that it should point to. Assigning values to the pointer itself will not work correctly.

    Try creating an otMasterKey object first, and pass its reference to the otThreadSetMasterKey function:

    otMasterKey otMasKey;
    
    otMasKey.m8[0] = 0xff;
    otMasKey.m8[1] = 0xee;
    otMasKey.m8[2] = 0xaa;
    otMasKey.m8[3] = 0xbb;
    otMasKey.m8[4] = 0xcc;
    otMasKey.m8[5] = 0x11;
    otMasKey.m8[6] = 0x00;
    otMasKey.m8[7] = 0x22;
    otMasKey.m8[8] = 0x33;
    otMasKey.m8[9] = 0x44;
    otMasKey.m8[10] = 0x55;
    otMasKey.m8[11] = 0x66;
    otMasKey.m8[12] = 0x77;
    otMasKey.m8[13] = 0x88;
    otMasKey.m8[14] = 0x99;
    otMasKey.m8[15] = 0xdd;
    
    otThreadSetEnabled(otIns,false);
    errornum = otThreadSetMasterKey(otIns,&otMasKey);
    otThreadSetEnabled(otIns,true);

  • Dear Jorgen:

    I have try it ,it's worked ,thank you very much 

Related