These above are the codes.
demo_printf("Sampled NodeId %d %lu\n", NodeId,"Sampled SignalSTR %d %lu\n", Signal,"Sampled FirmwareVER %d %lu\n", FirmwareVER,"Sampled battery %f %lu\n", batt,timestamp);
kaa_error_t error = kaa_logging_add_record(
kaa_client_get_context(kaa_client)->log_collector,
log_record, NULL);
以下是错误。我不明白错误是什么。到目前为止,C 语言的新手......似乎对于我的浮点变量,我不能使用 '%' 来执行我的 random() 函数。以下是错误:
/home/pi/try/client/c/src/kaa_demo.c: In function ‘send_temperature’:
/home/pi/try/client/c/src/kaa_demo.c:72:22: error: invalid operands to binary % (have ‘int’ and ‘double’)
float batt = rand() % 5.0;
^
/home/pi/try/client/c/src/kaa_demo.c:73:21: error: invalid operands to binary % (have ‘int’ and ‘double’)
float cel = rand() % 5.0;
^
/home/pi/try/client/c/src/kaa_demo.c:74:20: error: invalid operands to binary % (have ‘int’ and ‘double’)
float wt = rand() % 5.0; // kaa_logging_data_collection_t is the structure defined to contain temperature and time_stamp
^
/home/pi/try/client/c/src/kaa_demo.c:81:12: error: ‘kaa_logging_data_collection_t’ has no member named ‘NodeId’
log_record->NodeId = kaa_string_copy_create("Screws");
^
/home/pi/try/client/c/src/kaa_demo.c:82:15: error: ‘kaa_logging_data_collection_t’ has no member named ‘SignalSTR’
log_record->SignalSTR = Signal;
^
/home/pi/try/client/c/src/kaa_demo.c:83:12: error: ‘kaa_logging_data_collection_t’ has no member named ‘FirmwareVER’
log_record->FirmwareVER = kaa_string_copy_create("Linux KIDS");
^
/home/pi/try/client/c/src/kaa_demo.c:84:12: error: ‘kaa_logging_data_collection_t’ has no member named ‘OnlineStat’
log_record->OnlineStat = status;