Hi All,
My first post. awneil, your posts are very helpful. Thanks for your effort.
I have solved many problems from previous posts and the OpenAT Framework Tutorial, but I am stuck on this issue. Sorry if this is a fundamental C programming question but I have spend many frustrating hours on this.
I want to run my custom AT command via SMS. I know the adl_atCmdSend and adl_atCmdCreate will not work so I am trying to call my command handler function directly. I cannot figure out how to load the adl_atCmdPreParser_t struct correctly.
I am using the following function to test with.
void Test_ATJE(void) {
int i;
ascii aOrig[200], aPar[50];
static wm_lstTable_t ListTable = {
(void*)NULL,
(void*)NULL
};
adl_atCmdPreParser_t parms = {
.StrData[0] = 0, // Incoming command address ??? I don't get this syntax ???
.Type = ADL_CMD_TYPE_PARA, // Type
.NbPara = 0, // Number of parameters
.Port = ADL_PORT_NONE, // Port
.ParaList = wm_lstCreate(WM_LIST_NONE, &ListTable), // List of parameters
.StrLength = 0, // Incoming command length
.NI = 0, // Notification Identifier
.Contxt = (void*)NULL // Context
};
adl_atCmdPreParser_t *ppars;
sprintf(aOrig, "ATJE=10,20,30,40"); // My custom AT command test string
//parms.StrData = aOrig; // ??? crashes ???
sprintf(buff, "StrData[1] = %s", parms.StrData);
TRACE(( 2, buff ));
wm_lstClear(parms.ParaList);
for ( i=0 ; ; i++ ) {
if (wm_strGetParameterString(aPar, aOrig, i+1) == NULL)
break;
ret16 = wm_lstAddItem(parms.ParaList, (void*)aPar);
if (ret16 == ERROR)
sprintf(buff, "Add item %s ERRORed", aPar);
else
sprintf(buff, "Added item %s at position %d", aPar, ret16);
TRACE((2, buff ));
}
sprintf(buff, "pars.ParaList membersB - 0=%s, 1=%s, 2=%s, 3=%s",
(ascii*)wm_lstGetItem ( parms.ParaList, 0),
(ascii*)wm_lstGetItem ( parms.ParaList, 1),
(ascii*)wm_lstGetItem ( parms.ParaList, 2),
(ascii*)wm_lstGetItem ( parms.ParaList, 3));
TRACE((2,buff));
ppars = &parms;
sprintf(buff, "pars.ParaList membersA - 0=%s, 1=%s, 2=%s, 3=%s",
ADL_GET_PARAM(ppars, 0),
ADL_GET_PARAM(ppars, 1),
ADL_GET_PARAM(ppars, 2),
ADL_GET_PARAM(ppars, 3));
TRACE((2,buff));
parms.NbPara = (u8)wm_lstGetCount(parms.ParaList);
sprintf(buff, "Total added items = %d", parms.NbPara);
TRACE((2, buff ));
parms.StrLength = strlen(aOrig);
sprintf(buff, "pars.StrLength = %d", parms.StrLength);
TRACE((2, buff ));
if (strstr(aOrig, "ATJE?") > 0)
parms.Type = ADL_CMD_TYPE_READ;
if (strstr(aOrig, "ATJE=?") > 0)
parms.Type = ADL_CMD_TYPE_TEST;
ATJE_CMD_handler( &parms );
}
-
I don’t understand how ‘ascii StrData[1]’ can be used as a pointer as it is only one byte long. How do I use it to point to my string?
-
Am I doing the right thing by initializing parms, my instance of adl_atCmdPreParser_t?
-
Am I initializing and loading the wm_lst_t ParaList properly?
-
Should I be destroying anything before exiting this function?
Any assistance much appreciated.