Hi guys.
When I tried to compile my source, it failed saying
undefined reference to `port_clear_status(EVENT_GROUP_SELECT_T, unsigned long)'
.
Here is my directory structure.
- components
-- hal_param_manage
--------hal_param_manage.c
--------hal_param_manage.h
CMakeLists.txt
--linux_list
--------linux_list.c
--------linux_list.h
CMakeLists.txt
--main_config
-----main_config.c
------main_config.h
------ CMakeLists.txt
--port_debug
------- port_debug.h
------- CMakeLists.txt
--port_event
-------- port_event.c
-------- port_event.h
------- CMakeLists.txt
--port_timer
------- port_timer.c
------- port_timer.h
------- CMakeLists.txt
--wifi_app
------- wifi_device.c
------- wifi_device.h
------- CMakeLists.txt
-main
--------user_ main.c
-------CMakeLists.txt
Here is main.c source code.
代码: 全选
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "port_event.h"
#include "port_timer.h"
#include "main_config.h"
#include "port_debug.h"
#include "hal_param_manage.h"
#include "wifi_device.h"
#define APP_MAIN_DEBUG_TAG "main_debug"
char _uid[LQWY_DEV_UID_MAX_LENGTH] = {0}; /*全局64维数组,初始化为0*/
char _gid[LQWY_DEV_GID_MAX_LENGTH] = {0}; /*全局32维数组,初始化为0*/
int frame_interval_time = 0; /*全局uint32_t,初始化为0,帧上送时间间隔*/
/*esp32开发板型号:ESP32-WROOM-32*/
void app_main()
{
port_event_init() ; /*全局变量---创建事件组结构体中的各个事件组对象,用于线程间通信,全局事件组port_event结构体对象
port_event初始化*/
port_timer_sys_isr_init(0.05) ; //全局变量--50ms定时器中断初始化,全局定时器对象sys_port_timer初始化,并轮询定时器任务节点,调用定时器节点的回调函数
update_time_stamp(1582461934) ; /*设置UNIX时间戳*/
hal_param_init(); //定了了参数信息管理头结点和参数信息node节点,挂接在一起,然后循环遍历各节点,从flash读,读不到就写入节点默认值到nvs flash
//_uid,_gid,frame_interval_time全局过程变量初始化(从flash中读取并放入_uid中)
/*从flash中依据key,读出对应的值放入buf_value数组中,读取的长度是buf_len*/
if(hal_param_read((char *)LQWY_PARAM_UID_KEY,(uint8_t *)_uid,sizeof(_uid)) == PARAM_IS_OK) /*全局64维数组,初始化为0*/
{
ESP_LOGI(APP_MAIN_DEBUG_TAG,"gid %s \r\n",_uid);
}
if(hal_param_read((char *)LQWY_PARAM_GID_KEY,(uint8_t *)_gid,sizeof(_gid)) == PARAM_IS_OK) /*全局32维数组,初始化为0*/
{
ESP_LOGI(APP_MAIN_DEBUG_TAG,"uid %s \r\n",_gid);
}
/*全局uint32_t,初始化为0*/
if(hal_param_read((char *)LQWY_FRAME_SEC_KEY,(uint8_t *)&frame_interval_time,sizeof(frame_interval_time)) == PARAM_IS_OK)
{
ESP_LOGI(APP_MAIN_DEBUG_TAG,"frame_interval_time %d \r\n",frame_interval_time);
}
wifi_stack_init(); //After adding this call and component "wifi_app",project linking error,ohterwise project linking correct
return ;
}
the error file wifi_device.c->event handler
static void event_handler(void *arg, esp_event_base_t event_base,int32_t event_id, void* event_data)
{
EventBits_t uxBits = 0 ; //等待事件组某一位的返回值,真正的事件组位的值
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) //WIFI事件:站点启动
{
WIFI_DEV_DEBUG_I("SYSTEM_EVENT_STA_START\n");
esp_wifi_connect();
}
else if(event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) //站点模式断开
{
port_clear_status(WIFI_STATUS_SELECT, WIFI_STA_CONNECTED_BIT); //清零-STA模式已经连接上ap
WIFI_DEV_DEBUG_I("connect to the AP fail\n");
uxBits = port_get_status(WIFI_STATUS_SELECT,WIFI_STA_CONFIG_EN_BIT,pdFALSE,pdFALSE,0); //得到WIFI已配置位
if((uxBits & WIFI_STA_CONFIG_EN_BIT)) //已经配置
{
WIFI_DEV_DEBUG_I("config is ok pass is error\r\n");
port_clear_status(WIFI_STATUS_SELECT,WIFI_STA_CONFIG_EN_BIT); //清0-STA模式配置OK位
}
}
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { //站点模式得到IP
s_retry_num = 0;
port_set_status(WIFI_STATUS_SELECT, WIFI_STA_CONNECTED_BIT); //置1-STA模式已连接上热点
port_clear_status(WIFI_STATUS_SELECT,WIFI_STA_CONFIG_EN_BIT); //清0 STA配置使能位
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
WIFI_DEV_DEBUG_I(WIFI_Device_DEBUG_TAG,"got ip:" IPSTR, IP2STR(&event->ip_info.ip));
}
else if(event_id == WIFI_EVENT_AP_STACONNECTED) //作为热点模式已经被客户端连接
{
wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data;
WIFI_DEV_DEBUG_I(WIFI_Device_DEBUG_TAG, "station" MACSTR" join, AID=%d",MAC2STR(event->mac), event->aid);
port_set_status(WIFI_STATUS_SELECT,WIFI_AP_CONNECTED_BIT);
}
else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
WIFI_DEV_DEBUG_I(WIFI_Device_DEBUG_TAG, "station " MACSTR " leave, AID=%d",MAC2STR(event->mac), event->aid);
port_clear_status(WIFI_STATUS_SELECT,WIFI_AP_CONNECTED_BIT);
}
else if(event_id == WIFI_EVENT_SCAN_DONE) //完成了热点扫描
{
port_set_status(WIFI_STATUS_SELECT, WIFI_STA_SCAN_BIT);
WIFI_DEV_DEBUG_I(WIFI_Device_DEBUG_TAG,"SYSTEM_EVENT_SCAN_DONE");
}
}
port_set_status/port_clear_status is in components “port_event”。
app_main(main)->wifi_stack_init(wifi_app)->event_handler(wifi_app)->port_set/get_status(port_event)
What is wrong?
Sorry for such a beginner question,Dependces is correctly added.
The project is attached in the appendix.
windows enviroment,idf version is V5.3.0
undefined reference to `port_clear_status(EVENT_GROUP_SELECT_T, unsigned long)'
-
- Posts: 20
- Joined: Mon Jul 10, 2023 9:14 am
undefined reference to `port_clear_status(EVENT_GROUP_SELECT_T, unsigned long)'
- Attachments
-
- new1.rar
- project file
- (75.42 KiB) Downloaded 97 times
Last edited by greenstone on Mon Sep 02, 2024 6:58 am, edited 2 times in total.
-
- Posts: 20
- Joined: Mon Jul 10, 2023 9:14 am
Re: undefined reference to `port_clear_status(EVENT_GROUP_SELECT_T, unsigned long)'
windows enviroment,idf version is V5.3.0
-
- Posts: 20
- Joined: Mon Jul 10, 2023 9:14 am
Re: undefined reference to `port_clear_status(EVENT_GROUP_SELECT_T, unsigned long)'
我把 event_handler中调用的port_event组件中定义的port_set/get/clean_status函数,直接用xEventGroupSet/get/cleanBits(即freertos组件的API函数替代),工程编译就成功了。虽然成功,但是还想请大神指点下,自定义的组件,难道不能被别的组件访问吗?而且还加入了依赖,百思不得解。
Who is online
Users browsing this forum: Majestic-12 [Bot] and 166 guests