作者ortontherko (haha)
看板Electronics
标题[问题] 程式疑问
时间Thu Mar 17 22:03:50 2016
各位板上的高手好,小弟是一个大三生,目前在做cc3200的专题,碰到了一些困难还请各位指点:
具小弟我的理解cc3200在get时应该是从html call ccs里的callback function,并读取板子上的资讯将标签替换。
Callback funtion的部分 如下:
if(memcmp(pSlHttpServerEvent->EventData.httpTokenName.data, GET_sw,
strlen((const char *)GET_sw)) == 0)
{
status = getswstatus();
strLenVal = strlen(SW_STRING);
memcpy(ptr, SW_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
if(status & 0x01)
{
strLenVal = strlen(SW_ON_STRING);
memcpy(ptr, SW_ON_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
else
{
strLenVal = strlen(SW_OFF_STRING);
memcpy(ptr, SW_OFF_STRING, strLenVal);
ptr += strLenVal;
pSlHttpServerResponse->ResponseData.token_value.len += strLenVal;
}
*ptr = '\0';
}
Html 如下:
function UpdateStatus()
{
window.sessionStorage.clear()
var status = '__SL_G_USW;
if(status.indexOf("SW_ON") > -1)
{
toggleSwitch ('on');
alert('Hi, I am alert box.');
}
else
{
toggleSwitch ('off');
}
}
读取一次时没问题,但当我在html档里加
setInterval(function(){UpdateStatus()}, 1000);
时却发现他在重新读取时__SL_G_USW会直接被替换为一开始的SW_ON(OFF)值,我该如何才能让程式读取当前板子上的值,还请高手指点。
另外请教各位大大如果要做这片板子除了C、javascript还需要会什麽程式??我实在找不到方向,麻烦各位了,谢谢。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 36.226.129.46
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Electronics/M.1458223433.A.29A.html
※ 编辑: ortontherko (36.226.129.46), 03/17/2016 22:05:02
※ 编辑: ortontherko (36.226.129.46), 03/17/2016 22:05:34
1F:→ weiweider: 该不会你是学弟XD 03/18 23:04