如何在url发送浮动值,我发送浮动值,但得到空值
how to send float value in url , im sending float value but getting Null values
我想发送值并插入值到数据库中,但我得到空值。
float PHValue = Value/10;
float DOValue= 12.22;
gprsSerial.println("AT+HTTPPARA="URL","http://itempurl.com/smartpond/AddTemprature?WaterTemperature=""+celsius+""&PHValue=""+PHValue+""&DOValue=""+DOValue+""¤tTime=06-30-2016"");
您可以使用print()单独发送,如:
int n_decimals = 3;
float PHValue = Value/10;
float DOValue= 12.22;
gprsSerial.print("AT+HTTPPARA="URL","http://itempurl.com/smartpond/AddTemprature?WaterTemperature=");
gprsSerial.print(celsius, n_decimals);
gprsSerial.print("&PHValue=");
gprsSerial.print(PHValue, n_decimals);
gprsSerial.print("&DOValue=");
gprsSerial.print(DOValue, n_decimals);
gprsSerial.println("¤tTime=06-30-2016"");
对于n_decimals
,您希望打印的小数位数。
或者正如@stark在评论中所说,您可以使用snprintf
来生成您的AT命令:
char command[256];
float PHValue = Value/10;
float DOValue= 12.22;
snprintf(command, sizeof(command), "AT+HTTPPARA="URL",""
"http://itempurl.com/smartpond/AddTemprature?"
"WaterTemperature=%f&PHValue=%f&DOValue=%f"
"¤tTime=06-30-2016"", celsius, PHValue, DOValue);
gprsSerial.println(command);
注意:我不确定你是否希望url中的值在引号之间,所以我没有。
相关文章:
- 使用 const char* 键映射 C++ 检索空值
- 返回空值的字符串值
- boost::any 如何检查空值/未定义的值
- C++ - 无法从基类继承 |提供空值
- C++空值和此指针
- 使用 cin 或 getline() 输入空值
- 可变参数列表是否以空值终止?
- 如何将整数重新初始化/设置为空值
- 检查构造函数的空值
- 无法从Linux,C ++执行"my_script" python脚本"main(filename)"功能;pModule = PyImport_Import(pName);返回空值
- 使用Nlohmann JSON将JSON数据保存在文件中时获取空值
- 在命名空间中定义变量,但在测试中获取空值
- 将 CURL 转换为字符串时为空值
- QCharts - 在 QLineSeries 中创建一个中断(空值)
- 动态强制转换返回空值
- SDL 表面返回空值
- ptrA = ptrB 是否等同于 ptrA = &*ptrB?,空值是否共享一个地址空间?
- 如何将 libpq 中的空值与C++绑定
- 尝试访问 json dataC++ 时获取空值
- 如何在url发送浮动值,我发送浮动值,但得到空值