# adl\_atCmdCreate problem with adl\_atCmdSubscribe

**URL:** <https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808>\
**Category:** Open AT\
**Created:** [January 6, 2009, 11:29pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808 "2009-01-06T23:29:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfouilh](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@lfouilh](https://forum.sierrawireless.com/u/lfouilh)\
**Post date:** [January 6, 2009, 11:29pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/1 "2009-01-06T23:29:59Z")

</div>

Hello,

Here is my problem:

I declared a new AT command AT+NTPSERV :  
adl\_atCmdSubscribe ( “AT+NTPSERV”, Cmd\_NTPSERV\_Handler, ADL\_CMD\_TYPE\_READ | ADL\_CMD\_TYPE\_PARA | 0x0011 );

When using AT+SERV from the UART1 port of the Q24plus (over the eval board), it works fine.

However when using:  
adl\_atCmdCreate( “AT+NTPSERV?\r”, FALSE, ManageNewMessage\_Resp\_Handler, “\*”, NULL );

I received the ERROR message, while

adl\_atCmdCreate( “AT+CSQ\r”, FALSE, ManageNewMessage\_Resp\_Handler, “\*”, NULL ); works fine.

for info:  
bool ManageNewMessage\_Resp\_Handler(adl\_atResponse\_t \*paras)  
{  
adl\_atSendResponse ( ADL\_AT\_UNS, paras-\>StrData );  
return TRUE;  
}//endprog

Any idea?  
thank you for your help.

Laurent

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [January 7, 2009, 7:01am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/2 "2009-01-07T07:01:48Z")

</div>

adl\_atCmdCreate only works with the standard, built-in AT commands; You cannot use adl\_atCmdCreate to issue your own custom commands.

What would be the point? Just have your application call the appropriate function(s) direct! 8)

---

<div class="post-metadata">

**Author:** ![lfouilh](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@lfouilh](https://forum.sierrawireless.com/u/lfouilh)\
**Post date:** [January 7, 2009, 8:24am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/3 "2009-01-07T08:24:39Z")

</div>

Thank you awneil for your help.

My application handles a proprietary serial protocol.  
Serail frames start by “EA” (0x45 0x41) adn end by .  
For this reason I switch the UART1 in data mode, but I would like to be able to send my custom AT commands while in data mode.

Thank you for your help.

Laurent

---

<div class="post-metadata">

**Author:** ![wtb](https://avatars.discourse-cdn.com/v4/letter/w/53a042/32.png) [@wtb](https://forum.sierrawireless.com/u/wtb)\
**Post date:** [January 7, 2009, 1:00pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/4 "2009-01-07T13:00:41Z")

</div>

If you really want to do this, you should write your own wrapper to handle your custom AT commands.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [January 7, 2009, 1:08pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/5 "2009-01-07T13:08:31Z")

</div>

> [@wtb](#):
>
> write your own wrapper to handle your custom AT commands.

Or adapt your “proprietary serial protocol” to allow access to these commands…

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 9, 2009, 8:15pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/6 "2009-02-09T20:15:03Z")

</div>

I do have problem as well with atCmdCreate where i need to specify array pointer that will contain the value after the equal sign of the at comand.

This array sould be added the the cpbp at command.  
If i use the name of the array as followes:

adl\_atCmdCreate(“at+cpbp=“num””, FALSE, Handler, “\*”, NULL);  
With the above format I get search for the ascii vallue of -num- and not the value that is in the array pointer itself.

Adding the name of the array as follows after the comand itself will return an error.

adl\_atCmdCreate(“at+cpbp”+num, FALSE, Handler, “\*”, NULL);

Is there anyone knows how to add pointer to array in this adl ?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 9, 2009, 9:01pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/7 "2009-02-09T21:01:56Z")

</div>

> [@rami](#):
>
> Is there anyone knows how to add pointer to array in this adl ?

This has nothing to do with ADL - what you are doing is just not valid in ‘C’!

You need to use sprintf or similar to build your command string first, and then pass that string to adl\_cmdCreate…

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 10, 2009, 1:16am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/8 "2009-02-10T01:16:56Z")

</div>

> [@](#):
>
> what you are doing is just not valid in ‘C’!

yes i know the second one is not valid. i have tried all other options.

this one doesnt work as well;

[quote]  
wm\_strcpy(b,“at+cpbp=”);  
wm\_memset(b+8,0x5c,1); \ 0x5c=   
wm\_memset(b+9,0x22,1); \ 0x22="  
wm\_strcpy(b+10,num);  
wm\_memset(b+20,0x5c,1);  
wm\_memset(b+21,0x22,1);  
wm\_memset(b+22,0x22,1);

[quote]

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [February 10, 2009, 2:38am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/9 "2009-02-10T02:38:20Z")

</div>

Hiya,

> [@rami](#):
>
> wm\_strcpy(b,“at+cpbp=”);  
> wm\_memset(b+8,0x5c,1); \ 0x5c=   
> wm\_memset(b+9,0x22,1); \ 0x22="  
> wm\_strcpy(b+10,num);  
> wm\_memset(b+20,0x5c,1);  
> wm\_memset(b+21,0x22,1);  
> wm\_memset(b+22,0x22,1);

why don’t you try something like this instead (assuming that num is an integer):

```auto
wm_sprintf(b, "at+cpbp=%c%c%d%c%c%c", 0x5c, 0x22, num, 0x5c, 0x22, 0x22);
```

Look up the printf() and sprintf() functions to see how to format the string.

I wouldn’t try to print the resulting string to the console though…the control chars may bollox things up.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 7:41am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/10 "2009-02-10T07:41:21Z")

</div>

Or even:

> [@](#):
>
> wm\_sprintf( b, “at+cpbp="%d"”, num );

The more complicated you make it, the less likely you are to get it right!

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 7:46am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/11 "2009-02-10T07:46:54Z")

</div>

> [@rami](#):
>
> wm\_strcpy(b,“at+cpbp=”);  
> wm\_memset(b+8,0x5c,1); \ 0x5c=   
> wm\_memset(b+9,0x22,1); \ 0x22="  
> wm\_strcpy(b+10,num);  
> wm\_memset(b+20,0x5c,1);  
> wm\_memset(b+21,0x22,1);  
> wm\_memset(b+22,0x22,1);

> [@davidc](#):
>
> Hiya,  
> why don’t you try something like this instead (assuming that num is an integer):
> 
> ```auto
> wm_sprintf(b, "at+cpbp=%c%c%d%c%c%c", 0x5c, 0x22, num, 0x5c, 0x22, 0x22);
> ```

Neither of those will work, because they both insert backslash characters into the string!

You don’t actually want the backslash characters in the string - you just want the double quotes.

The backslash is just there to “escape” the double quotes when you enter them as part of a string!

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 10, 2009, 9:04am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/12 "2009-02-10T09:04:18Z")

</div>

it will take me days to find out that actually no one ever tried this before , but i am doubt about it…

can you please give an example how to put the at command ,concatenated with pointer to a buffer to the adl\_CmdCreat?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 9:07am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/13 "2009-02-10T09:07:54Z")

</div>

Again, this has nothing to do with Wavecom, OPen-AT or ADL. It’s basic, standard, textbook ANSI ‘C’ - use of sprintf.

Try doing it in a “normal” C compiler until you can get printf to display the string you want…

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 10, 2009, 10:48am UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/14 "2009-02-10T10:48:46Z")

</div>

Just sending the sprintf without relating it to the adl\_atCmdCreat will not give me anything.  
i did not understand what will sprintf contribute?

In order to use the at comand i need to specify the comand format in ascii to - ascii \*atstr , is that correct?  
as i said before adding the correct number to the at comand that i need to send is trivial ,  
it is the format of the string itself and the why it appers inside the array returns the error after jumping into this adl on the debuugging stage.  
I have tried to use b as the array that represents \*atstr with the following options:

b[]="at+cpbp=“0123456"”  
returns error

b[]="at+cpbp=“0123456"”  
returns error as well

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 1:25pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/15 "2009-02-10T13:25:36Z")

</div>

> [@rami](#):
>
> Just sending the sprintf without relating it to the adl\_atCmdCreat will not give me anything.  
> i did not understand what will sprintf contribute?

Use sprintf to build the string that you require.

If you don’t know how to do that in a “normal” C program outside of Open-AT and ADL, then you obviously won’t be able to do it with the added complications of Open-AT and ADL!

So get it going in a plain, vanilla “ordinary” C application first.

> [@](#):
>
> In order to use the at comand i need to specify the comand format in ascii to - ascii \*atstr , is that correct?

Yes

> [@](#):
>
> b="at+cpbp=“0123456"”  
> returns error

That will give you a compiler error - it is not valid ‘C’ syntax

> [@](#):
>
> b=“at+cpbp="0123456"”  
> returns error as well

You haven’t specified a type for ‘b’

If you don’t specify a type, ‘C’ will always default to int , which is not what you require - so it will cause an error.

Again, this is standard ‘C’ stuff - nothing specifically to do with Wavecom, Open-AT, or ADL.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 3:11pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/16 "2009-02-10T15:11:41Z")

</div>

> [@rami](#):
>
> returns error

You need to state clearly what, exactly, returns an eror - and what error, exactly, it returns!

eg:

- An error in your ‘C’ syntax will cause the compiler to give an error;
- An error in the way that you call adl\_atCmdCreate may cause that function to return an error result code;
- An error in the AT command itself will cause an ERROR response.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 3:21pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/17 "2009-02-10T15:21:11Z")

</div>

Here is an example of using sprintf to build a string and subsequently using that string:

```auto
#include <stdio.h>

int main( int argc, char* argv[] )
{
    // Strings to be formed into the message
    char hello_string[] = "Hello";
    char world_string[] = "world";

    // Buffer into which to build the message
    char string_to_print[80];

    // Build the message
    sprintf( string_to_print, "%s, %s!\n", hello_string, world_string );

    // Print it!
    printf( string_to_print );

    // all done.
    return 0;
}
```

You should be able to build that using any standard ‘C’ compiler to run it on a standard host system (not Open-AT).

Then experiment with adapting it to form the AT Command that you require…

Once you have that working, then move it into your Open-AT application…

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 10, 2009, 4:29pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/18 "2009-02-10T16:29:35Z")

</div>

> [@awneil](#):
>
> > [@rami](#):
> >
> > returns error
> 
> You need to state clearly what, exactly, returns an eror - and what error, exactly, it returns!
> 
> eg:
> 
> - An error in your ‘C’ syntax will cause the compiler to give an error;
> - An error in the way that you call adl\_atCmdCreate may cause that function to return an error result code;
> - An error in the AT command itself will cause an ERROR response.

The error is in the at command itself and it is +CME ERROR: 22 which means number is not existed.

I see it after a breakpoint that i put on the comand handler

```auto
bool Handler(adl_atResponse_t *paras)
{
    rs = (ascii *)adl_memGet(paras->StrLength); \\ Breakpoint is here 
    wm_strRemoveCRLF(rs, paras->StrData, paras->StrLength);
    wm_strcpy(buf,rs); \\buf = +CME ERROR: 22 
}
```

> [@](#):
>
> b="at+cpbp=“0123456"”  
> returns error
> 
> b=“at+cpbp="0123456"”  
> returns error as well

this is only an explenation of whats insid the srings that i send with the adl .

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [February 10, 2009, 5:03pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/19 "2009-02-10T17:03:46Z")

</div>

> [@rami](#):
>
> The error is in the at command itself and it is +CME ERROR: 22 which means number is not existed.

So you searched for a number that isn’t in the Phonebook - what result do you expect other than the error code indicating that the number isn’t in the Phonebook?! 😒

---

<div class="post-metadata">

**Author:** ![rami](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rami](https://forum.sierrawireless.com/u/rami)\
**Post date:** [February 10, 2009, 7:04pm UTC](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808/20 "2009-02-10T19:04:55Z")

</div>

as a matter of fact it exists. sending the comand threw terminal provides the correct number

[Next page](https://forum.sierrawireless.com/t/adl-atcmdcreate-problem-with-adl-atcmdsubscribe/2808.md?page=2)
