請問一下以 Sample code 為框架的一些開發觀念問題!!

YutingLin
Posts: 12
Joined: Wed Dec 12, 2018 6:14 am

請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby YutingLin » Tue Dec 18, 2018 5:28 am

各位版大好!!

小弟初次接觸這樣的開發系統跟套件
所以還有很多觀念不清楚的地方請多多包涵

我們公司目前想使用 ESP32 開發一個家用偵測系統
會將偵測資料上傳到雲端
以我們公司的產品開發應用
很自然就會選用 blufi (BLE+WiFi) 的 Sample code 框架
開發環境已經建好

在 blufi sample code 的框架當中
只做到可透過手機一個 APP BLE 介面
設定 device 要連線的 WiFi 主機名稱跟密碼
到目前測試都 OK


(另外請問這 Android 的 Test APP 有 source code 可提供參考嗎??)

但再進一步要測試上傳雲端資料功能時
有些觀念上的問題想不通,想請教一下

我們公司雲端測試主機接收資料方式是透過網址 URL 帶參數的方式
例如 : http://111.222.333.444/test.php?value1=11&value2=22

我有查找到似乎是要使用 esp_http_client 內的 function

在 blufi sample code 當中的 example_event_callback function 中
的 ESP_BLUFI_EVENT_GET_WIFI_STATUS 事件 中
我在 gl_sta_connected == true 裏直接使用

esp_http_client_config_t config = {
.url = "http://111.222.333.444/test.php?value1=11&value2=22",
.cert_pem = howsmyssl_com_root_cert_pem_start,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);

if (err == ESP_OK) {
ESP_LOGI(TAG, "Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
}
esp_http_client_cleanup(client);

會報錯!!
要開頭加上
#include "esp_http_client.h"
部分 function 才不會報錯,但還是有其他錯誤

我在想
那之後我要開發 BLE GPIO IIC UART ADC 等相關功能 function 也都是要這樣使用嗎????

我看 blufi 整包 code 的框架
build 資料匣裏就有很多相關的 LIB code
是要透過 make menuconfig 來開啟還是啥的嗎???

或許是我觀念錯誤,所以用法不對
還是說開發上就真的是要這樣使用???

請問有類似開發教學說明的網站嗎
還請知道的人賜教

謝謝!!

Weijian-Espressif
Posts: 29
Joined: Wed Aug 09, 2017 6:16 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby Weijian-Espressif » Tue Dec 18, 2018 8:19 am

Hi, Blufi APP 代码已经开源, 请参考 https://github.com/EspressifApp/EspBlufiForiOShttps://github.com/EspressifApp/EspBlufiForAndroid
blufi 协议 请参考 https://docs.espressif.com/projects/esp ... blufi.html

http 的问题我不了解, 稍后会有其他同事帮忙解答.

ESP_tuanpm
Posts: 14
Joined: Sat Dec 05, 2015 7:59 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby ESP_tuanpm » Tue Dec 18, 2018 8:50 am

Hi YutingLing,

Could you please provide the error logs after you #include "esp_http_client.h" and compile success?

YutingLin
Posts: 12
Joined: Wed Dec 12, 2018 6:14 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby YutingLin » Tue Dec 18, 2018 9:38 am

ESP_tuanpm wrote:
Tue Dec 18, 2018 8:50 am
Hi YutingLing,

Could you please provide the error logs after you #include "esp_http_client.h" and compile success?
Hi tuanpm :

#include "esp_http_client.h" 之後還有的錯誤
C:/msys32/home/Yuting/esp/blufi/main/blufi_example_main.c:266:33: error: 'howsmyssl_com_root_cert_pem_start' undeclared (first use in this function)
C:/msys32/home/Yuting/esp/blufi/main/blufi_example_main.c:272:30: error: 'TAG' undeclared (first use in this function)
make[1]: *** [/home/Yuting/esp/esp-idf/make/component_wrapper.mk:292: blufi_example_main.o] Error 1
make: *** [C:\msys32\home\Yuting\esp\esp-idf/make/project.mk:527: component-main-build] Error 2
make: *** Waiting for unfinished jobs....

都是一些宣告跟引用的問題

我使用的開發平台是 Eclipse
Properties -> C/C++ General -> Paths and Symbols 裡面的其他引用路徑也有設定

${IDF_PATH}/components/esp32/include
${IDF_PATH}/components/newlib/include
${IDF_PATH}/components/freertos/include
${IDF_PATH}/components/nvs_flash/include
${IDF_PATH}/components/driver/include
${IDF_PATH}/components/log/include

一樣也是不行

這些引用,應該找一下宣告的檔案再 include 進來就可解決
問題是,這樣的開發方式是正確的嗎???

ESP_Alvin
Posts: 195
Joined: Thu May 17, 2018 2:26 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby ESP_Alvin » Tue Dec 18, 2018 11:07 am

Hi, YutingLin

Would you help reply in English language? Our engineer ESP_Tuanpm could only read English language.

Thanks for your understanding.

Alvin
Best Regards

YutingLin
Posts: 12
Joined: Wed Dec 12, 2018 6:14 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby YutingLin » Wed Dec 19, 2018 1:31 am

ESP_tuanpm wrote:
Tue Dec 18, 2018 8:50 am
Hi YutingLing,

Could you please provide the error logs after you #include "esp_http_client.h" and compile success?
Hi Tuanpm :

I am having trouble with the ESP32 development framework.I currently use the Blufi smaple code framework to develop my product.But I also need to develop HTTP data transfer, OTA online update, IIC, ADC, GPIO and other related aspects of control functions.I use the Eclipse development platform, and the Blufi sample code is also compiled and executed.

But when I test to development of the HTTP transport function,I refer to other http sample code, and I get an error when compiling.I am adding in blufi_example_main.c->example_event_callback->ESP_BLUFI_EVENT_GET_WIFI_STATUS->gl_sta_connected == true

esp_http_client_config_t config = {
.url = "https://www.howsmyssl.com",
.cert_pem = howsmyssl_com_root_cert_pem_start,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);

if (err == ESP_OK) {
ESP_LOGI(TAG, "Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
}
esp_http_client_cleanup(client);

Compiled with such an error.
『C:/msys32/home/Yuting/esp/blufi/main/blufi_example_main.c:262:13: error: unknown type name 'esp_http_client_config_t'
esp_http_client_config_t config = {』

When I include the blufi_example.h file.Some bugs can be fixed. But there are still other errors.I know this is a related error in the reference file.What I want to ask is, is this the correct way of development?

Thanks a lot.

ESP_tuanpm
Posts: 14
Joined: Sat Dec 05, 2015 7:59 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby ESP_tuanpm » Wed Dec 19, 2018 4:10 am

Hi YutingLin

Yes, If you want to use esp_http_client you need to include "esp_http_client.h".
Similarly to other libraries, you need to include the header file before use. This is easy to see in the examples.

YutingLin
Posts: 12
Joined: Wed Dec 12, 2018 6:14 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby YutingLin » Wed Dec 19, 2018 6:08 am

ESP_tuanpm wrote:
Wed Dec 19, 2018 4:10 am
Hi YutingLin

Yes, If you want to use esp_http_client you need to include "esp_http_client.h".
Similarly to other libraries, you need to include the header file before use. This is easy to see in the examples.
Hi Tuanpm

So I understand that if I want to do integrated development, I have to rebuild my project architecture.Instead of using the sample code framework.And maintain related CMakeLists.txt files and other work.

It is recommended that your company can make the product development interface friendly, which is conducive to product application promotion and development.

Thank you for your answer.

costaud
Posts: 55
Joined: Wed Dec 30, 2015 5:09 pm

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby costaud » Wed Dec 19, 2018 10:00 am

這些引用,應該找一下宣告的檔案再 include 進來就可解決
問題是,這樣的開發方式是正確的嗎???
其实,idf中所有模块的功能都是以 component 的形式提供,需要使用某个功能,必须要include对应的头文件,这个对于c语言开发来说都是这样。对于使用来说,也有的开发者会习惯通过IDE来配置路径。
esp-idf 所有相关的文档都可以在这里查看:
https://docs.espressif.com/projects/esp-idf/en/latest/

不知道您有什么推荐的建议?

YutingLin
Posts: 12
Joined: Wed Dec 12, 2018 6:14 am

Re: 請問一下以 Sample code 為框架的一些開發觀念問題!!

Postby YutingLin » Wed Dec 19, 2018 10:31 am

costaud wrote:
Wed Dec 19, 2018 10:00 am
這些引用,應該找一下宣告的檔案再 include 進來就可解決
問題是,這樣的開發方式是正確的嗎???
其实,idf中所有模块的功能都是以 component 的形式提供,需要使用某个功能,必须要include对应的头文件,这个对于c语言开发来说都是这样。对于使用来说,也有的开发者会习惯通过IDE来配置路径。
esp-idf 所有相关的文档都可以在这里查看:
https://docs.espressif.com/projects/esp-idf/en/latest/

不知道您有什么推荐的建议?
不好意思,因為我對這樣的開發平台不是很孰悉,所以如題目上所說,可能是我觀念不太對的關係,我本身的開發經驗有寫過 PHP , 碰過一點 Android APP,uCOS 的開發,目前工作內容主要都是 MCU 類的專案,Linux 平台的軟體開發經驗比較少。

所以就我個人的整合開發習慣來說,我會將 WiFi 處理,BT 處理,HTTP 相關處理,OTA,GPIO......,各自獨立成一個檔案處理,全部都寫在同一個檔案上千行的 code 維護起來也不容易,在我開發 ST 系列跟 瑞薩 系列的 MCU,他們的開發 tool 滿完整的,會有個框架產生器可以使用,將基本的功能點選好後,就可產生一個開發框架,不太用去處理一些底層的複雜處理,其實這類似 LIB 的概念,只是中間又再多一層開發框架而已,畢竟這些 sample code 的其中一個用途,就是測試實作各種單一功能,但對整合性開發來說,這些基本功能卻都還要開發者自己去兜出都已經確定可以 work 的基礎功能,要能真正能進到應用開發,可能又是要一段時間了,就有如我現在要先孰悉 Linux 平台的軟體開發方式一樣,或許對於 Linux 平台很孰悉的人,對於這樣的開發環境覺得很正常,但對於不孰悉的人,要孰悉的話又要一段時間。

所以概念上的建議方向,主要就是要如何方便開發,有開發過多平台經驗的工程師,相信每次接觸新的平台時,光開發環境跟開發架構就很頭痛要花一段時間孰悉,C 的開發環境當然就都是這樣,Linux 也是由 C 寫的,但是要怎樣簡化這些基礎本來就應該要 ready 的事,是可以努力的一個方向。

Who is online

Users browsing this forum: No registered users and 39 guests