,,我需要到調制解調器它看起來像這樣提供的AT命令:AT^SRPN = 1,99991, 「DOWNLOAD_URL」, 「圖像」;^SMSOAT命令列表爲char *陣列
如何將變量download_url和變量圖像插入到命令字符串數組中?將命令數組聲明爲const並使用strcpy()將兩個變量插入命令列表是正確的方法嗎?
函數at_send_commands()需要命令列表爲const。 功能原型:at_resp_t at_send_commands(TickType ticks_to_wait, const char *commands[]);
at_resp_t at_send_download_url_and_image(const char *download_url, const char *image)
{
static const char *commands[] =
{
"AT^SRPN=1,99991,",
download_url,
",",
image,
";^SMSO\r",
NULL
};
at_resp_t err = at_send_commands(AT_TIMEOUT, commands);
if (err)
return err;
}
你的代碼不工作嗎?您收到錯誤嗎?你寫的方式,我不認爲命令[]需要是靜態的。但是,如果代碼已經不起作用,那不會有太大的改變。另外at_send_commands()的原型也是有用的。 – rozina
它肯定*不能*是靜態的,因爲它取決於運行時間值。 – unwind
好吧,我明白了......如果我在at_send_commands()中打印命令,我只看到「AT^SRPN = 1,99991」, – arge