Alios Things aos_kv_set和aos_kv_get用法

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);

    }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值