# Passing a Context to adl\_atCmdSendExt

**URL:** <https://forum.sierrawireless.com/t/passing-a-context-to-adl-atcmdsendext/2472>\
**Category:** Open AT\
**Created:** [September 1, 2008, 1:24pm UTC](https://forum.sierrawireless.com/t/passing-a-context-to-adl-atcmdsendext/2472 "2008-09-01T13:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabrizi0](https://sea1.discourse-cdn.com/flex025/user_avatar/forum.sierrawireless.com/fabrizi0/32/2742_2.png) [@fabrizi0](https://forum.sierrawireless.com/u/fabrizi0)\
**Post date:** [September 1, 2008, 1:24pm UTC](https://forum.sierrawireless.com/t/passing-a-context-to-adl-atcmdsendext/2472/1 "2008-09-01T13:24:20Z")

</div>

Hello,  
I try to call the function adl\_atCmdSendExt with a Context. I need to pass an argument to the callback and I think that the context should be the right way to do that. It seems that the Context is something different than what I thought, because it’s always reinitializated to a value I don’t understand.  
The documentation is not very clear, in this case, and I don’t find anything related in the forum. Am I missing something?

The following snippet prints a lcontext different than the value I passed as a Context.  
(BTW, ATI3 gives the following line: R71a01gg.Q2686H 2076692 052808 20:08 )

```auto
s16 atResp ( adl_atResponse_t *param )
{
    if( param->Contxt != NULL )
    {
        TRACE((1, "VALID CONTEXT"));
        u32 lContext= (u32)param->Contxt;
        TRACE((1, "lcontext: %d", lContext));
    }
    else
        TRACE((1, "NULL CONTEXT "));            
    return FALSE;    
}

void adl_main ( adl_InitType_e InitType )
{
    u32 iContext=12345;
    adl_atCmdSendExt("ati3", ADL_PORT_NONE, 0,(void*)iContext, (adl_atRspHandler_t)atResp, "R", NULL);
}
```

I wonder if there’s a clean way to pass an argument to the atResp callback. I don’t think that using globals is a good solution.  
Is there someone that could help me?

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![santi](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@santi](https://forum.sierrawireless.com/u/santi)\
**Post date:** [February 3, 2009, 8:52pm UTC](https://forum.sierrawireless.com/t/passing-a-context-to-adl-atcmdsendext/2472/2 "2009-02-03T20:52:29Z")

</div>

I’m having a similar problem.

I’m calling:

adl\_atCmdSendExt(“AT+WMSN”, ADL\_PORT\_OPEN\_AT\_VIRTUAL\_BASE, 0, ctx, at\_get\_cpu\_serial\_handler, “\*”, NULL)

where ctx is a pointer to a structure of the right size previously allocated with adl\_memGet. However, the Contxt field of the adl\_atResponse\_t is always initialized to the same value (and it’s not the address pointer by ctx!).

I’m going to check on a new firmware to see if there’s any difference… did you find any solution?
