aos_kv_set:
char rcvdataSets[512];
int len = strlen(rcvdataSets);
ret=aos_kv_set("KVrcv_data",rcvdataSets,len,3);
printf("rcvdataSets:%s\r\n",rcvdataSets);
printf("KV_SET:%d\n",ret);
温度阈值:
char tempthresholdSet[3];
itoa(tempthreshold,tempthresholdSet,10);
int len = strlen(tempthresholdSet);
int ret=aos_kv_set("KVTemperatureThreshold",tempthresholdSet,len,2);
printf("TemperatureThreshold:%lu,KV_SET:%d\n",item->valueint,ret);
aos_kv_get:
char rcvdataGet[512];
len = 512;
ret=aos_kv_get("KVrcv_data",rcvdataGet,len);
printf("rcvdataGet:%s\r\n",rcvdataGet);
printf("rcvdata KV_GET:%d\r\n",ret);
char tempthresholdGet[3];
int len = 3;
ret=aos_kv_get("KVTemperatureThreshold",tempthresholdGet,len);
tempthreshold=atoi(tempthresholdGet);
printf("TemperatureThreshold:%d,KV_GET:%d\n",tempthreshold,ret);
char pwmdataGet[256];
len = 256;
ret=aos_kv_get("KVpwm_data",pwmdataGet,len);
//printf("pwmdataGet:%s\r\n",pwmdataGet);
printf("pwmdata KV_GET:%d\r\n",ret);
const char s1[2] = ",";
char *token1;
token1 = strtok(pwmdataGet, s1);
int j=0;
pwmdata[j]=atoi(token1);
while( token1 != NULL ) {
if(j<6){
pwmdata[j]=atoi(token1);
//printf( "pwmdata[%d]:%d\r\n", j,pwmdata[j] );
}
if(j==6){
pwmdiv=atoi(token1);
//printf( "pwmdiv:%d\r\n", pwmdiv );
}
if(j==7){
rcvcount=atoi(token1);
//printf( "rcvcount:%d\r\n", rcvcount );
}
j++;
token1 = strtok(NULL, s1);
}
char rcvdataGet[512];
len = 512;
ret=aos_kv_get("KVrcv_data",rcvdataGet,len);
//printf("rcvdataGet:%s\r\n",rcvdataGet);
printf("rcvdata KV_GET:%d\r\n",ret);
const char s[2] = ",";
char *token;
token = strtok(rcvdataGet, s);
int i=0;
while( token != NULL ) {
if(i<rcvcount){
senddata[i].time_data_s=0;
senddata[i].time_data_e=0;
senddata[i].pwm_data_s=atoi(token);
//printf( "senddata[%d].pwm_data_s:%d\r\n", i,senddata[i].pwm_data_s );
}
else
{
senddata[i-rcvcount].pwm_data_e=atoi(token);
//printf( "senddata[%d].pwm_data_e:%d\r\n", i-rcvcount,senddata[i-rcvcount].pwm_data_e );
}
i++;
token = strtok(NULL, s);
}