Failed to change device name permanently

Hi,
I try to change my device name permanently using Macros- here is my code:
When I run the code, sometimes i get this error "Did not receive macro id within 250ms" . on the other times i get id=0 .Also, i do see the name changes bug after reset it returns to "MetaWear" , and i can see that the macro wasn't saved in flash
1. Do i miss something?
2. Can i increase the response time ?

```
metawear = Application.GetMetaWearBoard(mac);

        metawear.InitializeAsync().Wait();  


        IMacro macro = metawear.GetModule<IMacro>();  


        macro.EraseAll();  


        macro.StartRecord(true);  


        ISettings settings = metawear.GetModule<ISettings>(); 


        settings.EditBleAdConfig(name : newName)  


        byte id  =  await macro.EndRecordAsync();```

Comments

  • Follow the example code for erasing macros:
    https://mbientlab.com/csdocs/0/macro.html#erasing-macros

    I'm not sure what you mean by "response time"

    How are you resetting the board?

  • edited June 29

    Hi Eric,
    1. I re-wrote the code (see below) and it seems to give me the new name after calling ResetAsync. However, when i reset from MetaBase android app, the name goes back to "MetaWear". Is renaming devcie as "MetaWear" is part of the Metabse code? is there a difference from MetaBase "Reset" and "ResetAsync"? can you confirm that my code does the correct behavior for replacing name permanently?
    2. Is it normal that i get the Id for macro with value "0"? the Ids are zero based?
    3. how can i test the macro is working after FW reset beside using ResetAsync? when i will do "Hard restart" the macro will still be there?
    4. Should i do DisconnectAsync after ResetAsync? cause i tried and the code seems to be "hangout" in the line of the disconnect

                    ISettings settings;
                    IMacro macro;
        //Erase Macro 
                    metawear = Application.GetMetaWearBoard(mac);
                    metawear.InitializeAsync().Wait();
                    macro = metawear.GetModule<IMacro>();
                    settings = metawear.GetModule<ISettings>();
                    var st = await settings.ReadBleAdConfigAsync();
                    macro.EraseAll();
                    metawear.GetModule<IDebug>().ResetAfterGc();
                    await metawear.GetModule<IDebug>().DisconnectAsync();
    
            //connect again and record macro 
                    metawear = Application.GetMetaWearBoard(mac);
                    metawear.InitializeAsync().Wait();
                    settings = metawear.GetModule<ISettings>();
                    st=  await settings.ReadBleAdConfigAsync();
                    macro = metawear.GetModule<IMacro>();
                    macro.StartRecord(true);
                    settings.EditBleAdConfig(name : newName);
                    byte id  =  await macro.EndRecordAsync();
                    await metawear.GetModule<IDebug>().ResetAsync(); 
                     //  await metawear.GetModule<IDebug>().DisconnectAsync();
    
             //connect again
                    metawear = Application.GetMetaWearBoard(mac);
                    metawear.InitializeAsync().Wait();
                    settings = metawear.GetModule<ISettings>();
                    st = await settings.ReadBleAdConfigAsync();
    
  • edited July 2

    @abcd said:
    Hi Eric,
    1. I re-wrote the code (see below) and it seems to give me the new name after calling ResetAsync.

    I don't see any call to ResetAsync in your posted code.

    However, when i reset from MetaBase android app, the name goes back to "MetaWear". Is renaming devcie as "MetaWear" is part of the Metabse code? is there a difference from MetaBase "Reset" and "ResetAsync"?

    Search the forums before posting:

    https://mbientlab.com/community/search?Search="metabase+reset"

    can you confirm that my code does the correct behavior for replacing name permanently?

    1. Is it normal that i get the Id for macro with value "0"? the Ids are zero based?

    How IDs are created is irrelevant to the caller.

    1. how can i test the macro is working after FW reset beside using ResetAsync? when i will do "Hard restart" the macro will still be there?

    That is how to you test the macro.

    What is "hard restart"?

    1. Should i do DisconnectAsync after ResetAsync? cause i tried and the code seems to be "hangout" in the line of the disconnect

    Why are you interacting with the board after it has been reset? I don't see "ResetAsync" in your code anyways.

  • @Eric said:

    @abcd said:
    Hi Eric,
    1. I re-wrote the code (see below) and it seems to give me the new name after calling ResetAsync.

    I don't see any call to ResetAsync in your posted code.

    Actually, there is a call to ResetAsync- note the line " await metawear.GetModule().ResetAsync(); " at the end of the third block

    However when i reset from MetaBase android app, the name goes back to "MetaWear". Is renaming device as "MetaWear" is part of the Metabse code? is there a difference from MetaBase "Reset" and "ResetAsync"?

    Search the forums before posting:
    https://mbientlab.com/community/search?Search="metabase+reset"

    i did search but i assumed it is not relevant cause this is C++ thread. However, I read it now and i understood that metabase clears macros, and ResetAsync not (you called it "simple reset" in the thread. Is this correct?

    can you confirm that my code does the correct behavior for replacing name permanently?

    1. Is it normal that i get the Id for macro with value "0"? the Ids are zero based?

    How IDs are created is irrelevant to the caller.

    OK so getting 0 is normal..

    1. how can i test the macro is working after FW reset beside using ResetAsync? when i will do "Hard restart" the macro will still be there?

    That is how to you test the macro.

    What is "hard restart"?

    I mean Hard RESET... as explained at the MBIENTLAB TROUBLESHOOTING page [https://mbientlab.com/troubleshooting/ ] at Hard Reset (PROs ONLY) section...

    1. Should i do DisconnectAsync after ResetAsync? cause i tried and the code seems to be "hangout" in the line of the disconnect

    Why are you interacting with the board after it has been reset? I don't see "ResetAsync" in your code anyways.

    So there is not point to call disconnect after reset i understand. Is there is an option to add callback on disconnect asynch to do the rests in the c# SDK ?

  • edited July 6

    @abcd said:

    1. how can i test the macro is working after FW reset beside using ResetAsync? when i will do "Hard restart" the macro will still be there?

    That is how to you test the macro.

    What is "hard restart"?

    I mean Hard RESET... as explained at the MBIENTLAB TROUBLESHOOTING page [https://mbientlab.com/troubleshooting/ ] at Hard Reset (PROs ONLY) section...

    The first statement of that sections says

    If your device is completely unresponsive after following all the previous steps, you can perform a hard reset

    Why are you shorting the board if it is working fine?

    1. Should i do DisconnectAsync after ResetAsync? cause i tried and the code seems to be "hangout" in the line of the disconnect

    Why are you interacting with the board after it has been reset? I don't see "ResetAsync" in your code anyways.

    So there is not point to call disconnect after reset i understand. Is there is an option to add callback on disconnect asynch to do the rests in the c# SDK ?

    I'm not sure what you are asking here.

Sign In or Register to comment.