I would suggest that you do some reading about the C basics.
u8* Data
is infact a pointer to a byte buffer, or an array of bytes, depending on how you want to look at it.
It contains exactly DataLen elements, which can be accessed like this:
u8 myByte = Data[index]; // where 0 <= index < DataLen
Strictly speaking, ASCII is only 7 bits - so it’s a subrange (in Pascal-speak) of u8. 8)
Also, the ASCII codes below 0x20 are control codes.
Therefore, it isn’t generally safe to assume that any arbitrary u8 value is a “printable” character that can be safely sent through any arbitrary channel…
Ok thanks, I changed the handler…it now filled the string reply_txt2= “00000000000000000000000000”(28 zeros). The data I am sending is like this
" 512 512 1023 1023".
When programming for a device that has only 256KB of RAM you should always try to avoid temporary variables when possible, as well as statically initialized arrays:
ascii* reply_txt2; // Reply SMS text
bool fcmDataHdlr (u16 DataLen, u8 *data)
{
reply_txt2 = adl_memGet(DataLen * 2 + 1); // if you want it to be really robust, check that the return value is not equal to NULL
wm_memset(reply_txt2, 0, DataLen * 2 + 1); // check the syntax here, maybe the last two parameters should be swapped
wm_ibuftohexa(reply_txt2, data, DataLen);
return TRUE;
} // don't forget to free reply_txt2 when you don't need it anymore
I was reading the problems about communication throw UART2.
Can somebody tell me how to initialise uart2 so I can receive messages from it.
I did already try adl_fcmSubscribe but the controlhandler and data handler don’t work.
The uart is enabled. at+wmfm? -> 0,2,2,1
I can send at commands to uart2 and the q2686 responds.
But I want to send other data over uart2. On page 102 of the adl user guide they draw a switch (1).
How can I set the switch in the software to the other position?
I did wrote this function in the software.
The cntrlhandler (fcmsubscribe) is retuning ADL_FCM_EVENT_FLOW_OPENNED.
The switch function is returning 0 (so OK). But still uart2 is responding on at commands while software said that the switch is set.
If I send ascii code to that uart (using hyperterminal) DataHandler should be called and that doesn’t happened.
I did find the problem. After receiving ADL_FCM_EVENT_FLOW_OPENED I have to call adl_fcmSwitchV24State and not before.
Otherwise the switch won’t work.
Thanks a lot for the help.