一、實(shí)驗(yàn)名稱
智慧園區(qū)能源管控系統(tǒng)
二、實(shí)驗(yàn)?zāi)康?/h1>
能夠在onenet云平臺上看到硬件檢測到的數(shù)據(jù)的效果、運(yùn)用postman、intellij IDEA等軟件來達(dá)到實(shí)驗(yàn)效果。
三、實(shí)驗(yàn)步驟
3.1.修改“寫回調(diào)函數(shù)”
// "寫"回調(diào)函數(shù)
void write_callback(
uint16_t objid,
uint16_t instid,
uint16_t resid,
nbiot_value_t *data)
{
printf("write /%d/%d/%d:%d\r\n",
objid,
instid,
resid, data->value.as_bool);
if (objid == 3311 && instid == 0 && resid == 5850) /* LED燈 */
{
if(data->value.as_bool)
{
// 打開白色背光以模擬LED燈開
Lcd_Clear(WHITE);
ledStatus.Led1Sta=1;
}
else
{
// 打開黑色背光以模擬LED燈關(guān)
Lcd_Clear(BLACK);
ledStatus.Led1Sta=0;
}
}
}
3.2.添加“讀回調(diào)函數(shù)”
void read_callback(
uint16_t objid,
uint16_t instid,
uint16_t resid,
nbiot_value_t *data)
{
if (objid == 3303 && instid == 0 && resid == 5700) { /* 溫度 */
SHT20_INFO sht20 = { 0 };
sht20 = SHT20_GetValue();
temp.value.as_float = sht20.tempreture;
} else if (objid == 3304 && instid == 0 && resid == 5700) { /* 濕度 */
SHT20_INFO sht20 = { 0 };
sht20 = SHT20_GetValue();
humi.value.as_float = sht20.humidity;
} else if (objid == 3301 && instid == 0 && resid == 5700) { /* 光照 */
BH1750_test();
illumi.value.as_float = result_lx;
} else if (objid == 3311 && instid == 0 && resid == 5850) { /* LED */
led.value.as_bool = ledStatus.Led1Sta;
}
}
3.3.資源列表

image.png
3.4平臺控制

image.png
3.5.POSTMAN上調(diào)用API

image.png

image.png
3.5.在intellij IDEA上修改參數(shù)

image.png
3.5.數(shù)據(jù)成功推送

image.png
實(shí)驗(yàn)總結(jié)
經(jīng)過這次實(shí)驗(yàn),我能更熟練得使用onenet云平臺,鍛煉了我發(fā)現(xiàn)問題和解決問題的能力、團(tuán)隊(duì)合作的能力;對postman、intellij IDEA等軟件的運(yùn)用也更加熟練