Compare commits

..

No commits in common. "062d48388031d649ba73f02e8c061fa307da6ffe" and "9591653e439829ef81b3f38c9034f18fc46b97fc" have entirely different histories.

2 changed files with 7 additions and 8 deletions

View File

@ -3,7 +3,7 @@ import os
cwd = GetCurrentDir()
src = [
'mqtt.c',
'filesystem.c',
]
CPPPATH = [cwd]

View File

@ -23,7 +23,6 @@ int HAL_Snprintf(char *str, const int len, const char *fmt, ...);
//定义接受文件内容的缓冲区
char buffer[100] = {};
char tmp[256];
#define GPIO_LED_B GET_PIN(F,11)
#define GPIO_LED_R GET_PIN(F,12)
@ -101,19 +100,19 @@ static int example_subscribe(void *handle)
return 0;
}
void make_file()
void make_file(char *String)
{
//文件描述符
int fd;
// String = "Hello, RT-Thread.Welcom to RSOC!\n temp: 123, humi: 789";
String[] = "Hello, RT-Thread.Welcom to RSOC!\n temp: 123, humi: 789";
//用只写方式打开文件,如果没有该文件,则创建一个文件
fd = open("/fal/test/Data.txt", O_APPEND | O_CREAT);
fd = open("/fal/test/Data.txt", O_WRONLY | O_CREAT);
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,String);
//如果打开成功
if (fd >= 0)
{
//写入文件
write(fd, tmp, sizeof(tmp));
write(fd, String, sizeof(String));
// rt_kprintf("Write done.\n");
@ -151,14 +150,14 @@ void make_file()
}
return;
}
char tmp[256];
int cnt = 0;
void tmp_payload(void)
{
// 读取温湿度值
Humi = aht10_read_humidity(Dev);
Temp = aht10_read_temperature(Dev);
memset(tmp, 0, sizeof(tmp));
sprintf(tmp, "Temp: %f;Humi: %f;Count: %d\n", Temp, Humi,++cnt);
sprintf(tmp, "Temp:%f;Humi:%f;Count:%d", Temp, Humi,++cnt);
// rt_kprintf("\n%f %f tmp:%s\n",Humi,Temp,tmp);
make_file(tmp);
sprintf(tmp, "{\"params\":{\"temperature\":%.2f,\"humidity\":%.2f}}", Temp, Humi);