Strange problem about adl_flhSubscribe


#1

there are two source code text bellow. the first one is subscribed successfully, but the second one is error and returns “ADL_RET_ERR_PARAM”, I don’t know why .could anyone give a exaplaination?

example 1.

//*****************************************************************************/
//when input "AT+FLASH+S", the SubFlash is called, then it returns 
//" Input String is:at+flash=s"
//"SubFlash: ADL_RET_ERR_PARAM"
//*****************************************************************************/

static adl_atCmdPreParser_t Cmd;//adl_atCmdPreParser structure 
char* FlashHdl;//The Handle of the set of objects to subscribe to
/***************************************************************************/
/*  This function subscribes to a set of objects identified */
/* Input: NbObjectRes   The number of objects related to the given handle. I   */
/***************************************************************************/
void SubFlash(u16 NbObjectsRes)
{
    s8 FlashRe;
    FlashRe = adl_flhSubscribe ( FlashHdl, NbObjectsRes);
    //print the debug information to UART1
    switch (FlashRe)
    {
        case OK:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: OK\r\n" );
            break;
        case ADL_RET_ERR_PARAM:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_PARAM\r\n" );
            break; 
        case ADL_RET_ERR_ALREADY_SUBSCRIBED:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_ALREADY_SUBSCRIBED\r\n" );
            break;         
        case ADL_FLH_RET_ERR_NO_ENOUGH_IDS:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_FLH_RET_ERR_NO_ENOUGH_IDS\r\n" );
            break;                   
        case ADL_RET_ERR_SERVICE_LOCKED:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_SERVICE_LOCKED\r\n" );
            break;
    }
}

void CmdFlashhdl( adl_atCmdPreParser_t *Cmd )
{
    char cmdbuf[100];

    //output the reveived command to UART1.
    wm_memcpy(cmdbuf,Cmd->StrData,Cmd->StrLength);
    cmdbuf[Cmd->StrLength]=0;
    adl_atSendResponse ( ADL_AT_UNS,"\r\n Input String is:" );
    adl_atSendResponse ( ADL_AT_UNS,cmdbuf );
    
    //check the command, if the command is "AT+FLASH=S" then call SubFlash. 
    switch (cmdbuf[9])
    {
        case 'S'://subscribe the flash area
        case 's':
            SubFlash(5);      
        break;   
        default:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n Cmd ERROR \r\n" );
    }
}

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded Application : Main" ));
    
   //subscribe the "AT+FALSH=" command from UART1.
    adl_atCmdSubscribe ( "AT+FLASH=", CmdFlashhdl, ADL_CMD_TYPE_ROOT);
    
    adl_atSendResponse ( ADL_AT_UNS, "\r\nStart get the information of Ram and Flash!\r\n" );

}

example 2

//*****************************************************************************/
//when input "AT+FLASH+S", the SubFlash is called, then it returns 
//" Input String is:at+flash=s"
//"SubFlash: OK" 
// that is waht I want.
//*****************************************************************************/

static adl_atCmdPreParser_t Cmd;//adl_atCmdPreParser structure 
char* FlashHdl;//The Handle of the set of objects to subscribe to
/***************************************************************************/
/*  This function subscribes to a set of objects identified */
/* Input: NbObjectRes   The number of objects related to the given handle. I   */
/***************************************************************************/
void SubFlash(u16 NbObjectsRes)
{
    s8 FlashRe;
    FlashRe = adl_flhSubscribe ( FlashHdl, NbObjectsRes);
    //print the debug information to UART1
    switch (FlashRe)
    {
        case OK:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: OK\r\n" );
            break;
        case ADL_RET_ERR_PARAM:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_PARAM\r\n" );
            break; 
        case ADL_RET_ERR_ALREADY_SUBSCRIBED:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_ALREADY_SUBSCRIBED\r\n" );
            break;         
        case ADL_FLH_RET_ERR_NO_ENOUGH_IDS:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_FLH_RET_ERR_NO_ENOUGH_IDS\r\n" );
            break;                   
        case ADL_RET_ERR_SERVICE_LOCKED:
            adl_atSendResponse ( ADL_AT_UNS,"\r\n SubFlash: ADL_RET_ERR_SERVICE_LOCKED\r\n" );
            break;
    }
}

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded Application : Main" ));
      
    adl_atSendResponse ( ADL_AT_UNS, "\r\nStart get the information of Ram and Flash!\r\n" );

    //call SubFlash 
    SubFlash(5);
}

#2

Please use the ‘Code’ tags (eg, by using the ‘Code’ button) to post source code legibly.

And use ‘Preview’ to check it before posting.

How do you set FlashHdl :question:


#3

I have added the code tags.


#4

Have you?

But you didn’t check the ‘Preview’, did you? :unamused:

It’s still illegible because it’s lost all its indenting, hasn’t it?

When you add the ‘Code’ tags, it would look like this:

void adl_main ( adl_InitType_e InitType )
{
   TRACE (( 1, "Embedded Application : Main" ));

   adl_atSendResponse ( ADL_AT_UNS, "\r\nStart get the information of Ram and Flash!\r\n" );

   //call SubFlash 
   SubFlash( 5 );
}

You still didn’t answer where you set FlashHdl :question: