This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:Code Composer Studio
大家好、
我正在尝试对 cc2650 sensortag 进行一些高级调试 ,并注意到当我多次调用 System_printf()时,内容在第一次调用后不显示。
例如、如果我执行以下操作:
system_printf ("hello world 1\n"); System_printf ("hello world 2\n"); System_printf ("hello world 3\n");
我希望显示:
大家好、1 大家好、2 大家好、3
但是、仅显示"Hello world 1"、其余不显示。
与这些类型的问题的常见情况一样、我对 CCS 和 Sensortag 的开发非常陌生、对 C 语言的开发也相当陌生、因此任何启发都很有帮助。
我的 app_ble.cfg 文件如下所示:
utils.importFile ("..//../../../../src/common/cc26xx/kernel/cc2640/config/cc2640.cfg); // *扩展 cc2640配置 */ var SysStd = xdc.useModule("xdc.runtime.SysStd"); var System = xdc.useModule("xdc.runtime.System"); System.SupportProxy = SysStd;
Thom、您好!
我建议您使用 Display_printf 将调试输出路由到 UART。 请查看 Display 示例以了解相关示例。
您可以使用 System_printf 并将字符路由出 UART、但我们为其他器件提供的 UARTUtils 文件将不起作用、因为 CC26xx 器件未实现 UART_writePolling。
Todd
[更正了 UARTConsole -> UARTUtils]
感谢您的帮助!
我一生中都不明白可能出什么问题。 我认为我应该连接到终端中的 COM8端口。
我将其设置为9600波特、数据大小、奇偶校验位和停止位分别设置为8、无和1。
它显示已连接(或至少没有问题)
下面是我尝试访问 UART 显示内容的当前代码:
//包括 #include // Globals Display_Handle dispHandle = NULL; Display_Params params; //在 SensorTag_taskFxn () Display_Params_init (¶ms); params.lineClearMode = Display_clear_both; dispHandle = Display_open (Display_Type_UART、¶ms); if (Handle){dispHandle) Display_print0 (dispHandle、0、0、"Hello Serial!"); }
我目前正在 SensorTag_taskFxn()内的 sensortag.c 内初始化此显示代码。 这是一种糟糕的方法吗? 我目前不知道。
"dispHandle"返回0、我认为这意味着无法打开显示端口、如果这有帮助。
我使用的是 C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650stk\sensortag。 我将尝试让 C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650stk\simple_peripheral 立即工作、看看我是否有更好的运气。 我还在9600和115200之间来回切换波特率、以查看两者是否起作用。
我似乎再找不到 sensortag 代码的在线链接了
是的、我在查找 simple_peripheral 和 Display 示例之间可能缺少的内容时遇到了困难。 实际上、我最终能够让 Display 示例在本地工作。 我在 simple_peripheral.c 内的 SimpleBLEPeripheral_init 末尾初始化 Display_open
我有什么问题吗? 我不明白这会让我疯了。 是否缺少构建设置?
这是我的 simple_peripheral.c 文件:
/********* @文件 simple_peripheral.c @简介此文件包含要使用的简单 BLE 外设示例应用 CC2650低功耗蓝牙协议栈进行通信。 组:WCS、BTS 目标设备:CC2650、CC2640 版权所有(c) 2013-2018、德州仪器(TI)公司 保留所有权利。 只要 满足以下条件、就允许以源代码和二进制形式重新分发和使用(无论是否修改): *源代码的重新分发必须保留上述版权 声明、此条件列表和以下免责声明。 *二进制形式的再发行必须复制上述版权 注意、本条件列表和中的以下免责声明 分发时提供的文档和/或其他材料。 *德州仪器公司的名称和名称均不相同 其贡献者可用于认可或推广衍生产品 未经特定的事先书面许可。 本软件由版权所有者和贡献者"按原样"提供 、 不承认任何明示或暗示的保证、包括但不限于对适销性和特定用途适用性的暗示保证。 在任何情况下、版权所有者或 贡献者都不对任何直接、间接、偶然、特殊、 模范、 或相应的损害(包括但不限于 采购替代产品或服务;丧失使用、数据或利润; 或业务中断)、但出于任何责任理论、 无论是在合同中、严格责任还是在使用 本软件时以任何方式产生的侵权行为(包括疏忽或其他原因)、 即使被告知存在此类损坏的可能性。 秘书长的报告 发布名称:BLE_SDK_2_02_02_25 发布日期:2018-04-02 18:03:35 / /********* *包括 */ #include #include #include #include #include #include #include include "hci_tl.h"#include "gatt.h"#include "linkdb.h"#include "gapgattserver.h"#include "gattservapp.h"#include "devinfoservice.h"#include "simple_gatt_profile.h"#include "image_invalidate #include "nosrg.h"#include "#include "nodecnature.h"#include "#include "nature.h"#include "#include "nosrnature.h"#include "#include "nature.h"#include "#include "#nec.h"#include "nature.h"#include "#nature.intr.nature.h"#nature.h"#include "#nature.nec.h"#include "#nature.h"#include "#nature.intr.nec.nec.h"#include "#include "#nature.h"#include "#nature.intr.nature.h use_fpga)|| Defined (debug_sw_trace) #include #endif // use_fpga | debug_sw_trace /********* *常量 */ //可发现器件时的广播间隔(单位625us、160=100ms) #define DEFAULT_advertising_interval 160 //受限可发现模式广播30.72,然后停止 //一般可发现模式广播无限 #define DEFAULT_DISCOVERADE_MODE GAP_ADTYPE_FLAGS_General #ifndef FITY_OAD //最小连接间隔(单位为1.25ms、80=100ms)(如果 启用了自动//参数更新请求 )#define DEFAULT_MILLED_CONN_INTERVAL 80 //如果 启用了自动//参数更新请求 ,则最大连接间隔(单位为1.25ms,800=1000ms)#define DEFAULT_REGIND_MAX_CONN_INTERVAL 800 #else //!feature_OAD //最小连接间隔(单位为1.25ms、8=10ms)(如果 启用了自动//参数更新请求 #define default_desired _min_conn_interval) 8 //如果启用了自动 //参数更新请求 #define DEFAULT_RETOVE_MAX_CONN_INTERVAL,则最大连接间隔(单位为1.25ms,8=10ms) 8 #endif // feature_OAD //启用自动参数更新请求时使用的从器件延迟 #define default_desired slave_latency 0 //如果启用了自动参数 //更新请求 #define DEFAULT_MILLED_CONN_TIMEOUT,则监控超时值(10ms、1000=10s 的单位) 1000 //连接时是否启用自动参数更新请求 //形成 #define DEFAULT_ENABLE_UPDATE_REQUEST GAPROLE_LINK_PARAM_UPDATE_INITIATE_NOT_PARAMS //连接暂停外设时间值(以秒为单位) #define DEFAULT_CONN_PAUSE_PERIFTLE 6 //执行周期性事件的频率(以 msec 为单位) #define SBP_PERIOD_EVT_PERIOD 5000 #ifdef FITY_OAD // OAD 数据包的大小。 #define OAD_PACKET_SIZE (((OAD_BLOCK_SIZE)+ 2) #endif // Feature_OAD //任务配置 #define SBP_TASK_PRIORITY 1 #ifndef SBP_task_stack_size #define SBP_task_stack_size 644 //#define SBP_TASK_STACK_SIZE 768 #endif // RTOS 应用 程序的内部事件#define SBP_State_change_EVT 0x0001 #define SBP_CHAR_CHANGE_EVT 0x0002 #define SBP_Period_EVT 0x0004 #define SBP_CONN_EVT_END_EVT 0x0008 /********* * typedef */ //从配置文件传递的应用程序事件。 typedef 结构 { appEvtHdr_t HDR;//事件头。 } sbpEvt_t; /********* *全局变量 */ //显示接口 Display_Handle dispHandle =空; /********* *局部变量 */ //全局实体 ID 用于检查消息的源和/或目标 静态 iCall_EntityID selfEntity; //全局信号量用于将事件发布到应用程序线程 静态 iCall_Semaphore SEM; //内部周期性事件的时钟实例。 静态时钟结构周期时钟; //用于应用消息的队列对象 static Queue_StructapMsg; static Queue_handle appMsgQueue; #if defined (feature_OAD) //来自 OAD 配置文件的事件数据。 静态 Queue_StructoadQ; 静态 Queue_handle hOadQ; 内部 应用事件的#endif //feature_OAD //事件标志。 静态 uint16_t 事件; //任务配置 Task_StructsbpTask; Char sbpTaskStack[SBP_task_stack_size]; //配置文件状态和参数 //静态 gaprole_states_t gapProfileState = GAPROLE_init; // GAP -扫描 RSP 数据(最大大小= 31个字节、'sscan_statuss_t) 、'sapProfile'、't 名称= GAPROLE_COMPLE_COMPLE_END'、't、'sand'、's_COMPLE'、's20_END' 'L'、 'e'、 'B'、 'L'、 'E'、 'p'、 'e'、 'r'、 'i'、 'p'、 'h'、 'e'、 'r'、 'a'、 'l'、 //连接间隔范围 0x05、//此数据 的长度 GAP_ADTYPE_SLAVE_CONN_INTERVE_RANGE、 LO_UINT16 (DEFAULT_REAVE_MIN_CONN_INTERVAL)、// 100ms HI_UINT16 (DEFAULT_REAVE_MIN_CONN_INTERVAL)、 LO_UINT16 (DEFAULT_MAX_ON_MIN_INTERVAL )、LO_CONTRATE (DEFAULT_INT_CONTRATE)/ CONTRATE // Tx 功率级别 0x02、//此数据 的长度 GAP_ADTYPE_POWER_LEVEL、 0 // 0dBm }; // GAP -广播数据(最大大小= 31字节、尽管这是 //在进行广播时最好保持较短的时间以节省功耗) 静态 uint8_t advertData[]= { // Flags;这会将器件设置为使用有限 的//模式(一次可发现30秒) 不是通用 //可发现模式(无限期广播) 0x02,//此数据 GAP_ADTYPE_FLAGS 的长度, DEFAULT_DISCOVE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED, //服务 UUID,通知中央设备包含哪些服务 //在此外设中 #if!defined (feature_O03)||(feature 0xOAD_NOT_SUPPORTED), 0x05,0xOAD_OAD/ EXLETE,0xOAD/ EXTERIN //此数据的长度 #endif //feature_OAD GAP_ADTYPE_16BIT_more、 //一些 UUID,但并非所有 #ifdef Feature_OAD LO_UINT16 (OAD_SERVICE_UUID )、 HI_UINT16 (OAD_SERVICE_UUUUUUUUUUUUUUID)、 #endif //Feature_OAD #ifndef Feature_OAD_ONCHIP LO_UINT16 (SIMPLE_PROFILE_DEVICE_UPT)、#NAPPLATT_RESET_8 和#NPOINT_RESET_RESET_RESET_INT_RESTON_INT_PROTOOTH = 0 * 0和#PROTOOT_PROTOOT_ENT_PROTOOT_INT_PROTOP_8 *#PROTOP_ENT_PROTOP_8和#PROTOP_ENT_PROTOP_ENT_PROTOP_ENT_PROTOP_ENT_ENT_PROTOP_ENT_UNT_PROTOP_ENT_UNT_PROTOP_ENT_UNT_PROTOP_8 * INT_PROTOP_8 * INT_PROTOP_ENT_PROTO *本地函数 */ static void SimpleBLEPeripheral_init (void); static void SimpleBLEPeripheral_taskFxn (UArg a0、UArg A1); static uint8_t SimpleBLEPeripheral_processStacks(ivid SimpleBLEPeripheral_process); static SimpleStack_static Ward_static SimpleBLEBLE_static Ward_static Ward_static Br (void );static SimpleStack_static SimpleStack_static BLE_static BLE_static BLE_static Br (void) 静态空 SimpleBLEPeripheral_stateChangeCB (gaprole_states_t newState); #ifndef feature_OAD_ONCHIP 静态空 SimpleBLEPeripheral_charValueChangeCB (uint8_t ChangeID); #endif //!feature_OAD_ONCHIP 静态空 SimpleBLEPeripheral_enuint8;#endifut static 、#endif out_enuint8_enuint8和 event_enuintuintu_event_enuint8 uint8_t *pData); #endif //feature_OAD /********* * extern 函数 */ extern void AssertHandler (uint8 ****CasertCasuse、uint8 assertSubcause); / *配置文件回调 */ // GAP 角色回调 静态 gapRolesCBs_t SimpleBLEPeripheral_gapRoleCBs = { SimpleBLEPeripheral_stateChangeCB //配置文件状态更改回调 }; // GAP 绑定管理器回调 静态 gapBondCBs_t simpleBLEPeripheral_BondMgrCBs = { NULL,//密码回调(不被应用程序使用) NULL //配对/绑定状态回调(不被应用程序使用) }; //简单 GATT 配置文件回调 #ifndef FEATE_OAD_ONCHIP 静态 simpleProfileCBs_t SimpleBLEPeripheral_simpleProfileCBs = { SimpleBLEPeripheral_charValueChangeCB//特征值更改回调 }; #endif //!Feature_OAD_ONCHIP #SimplePeripheral_OSimpleLink = SimplePeripheral_WriteBAD_OCCB =静态值更改回调};#endif // ! }; #endif //feature_OAD/ ********* *公共职能 */ *@fn SimpleBLEPeripheral_createTask * *@简单 BLE 外设的简短任务创建函数。 * *@param 无。 * *@返回无。 // void SimpleBLEPeripheral_createTask (void) { Task_Params taskParams; //配置任务 Task_Params_init (&taskParams); taskParams.stack = sbpSTACKStack;taskParams.TaskCKSIZE = SBP_TASK_STACK_SIZE; taskParams.priority = SBP_TASK_TASK_PRIZE = SBP_TASK_TASK_TASK_TASK_BACK_PRIVE_TASK; task_TASK_TASK ( SimpleBLEPeripheral_taskFxn、&taskParams、NULL); } /********* *@fn SimpleBLEPeripheral_init * *@初始化期间调用的简短说明、其中包含应用 * 特定初始化(即硬件初始化/设置、 * 表初始化、加电通知等)和 * 配置文件初始化/设置。 * *@param 无。 * *@返回无。 */ static void SimpleBLEPeripheral_init (void) { //****** //在调用 iCall_registerApp 之前可能会发生 N0栈 API 调用 // //将当前线程注册为 ICall 调度程序// 以便应用程序可以发送和接收消息。 iCall_registerApp (&self 实体、&sem); #ifdef USE_RCOSC RCOSC_enableCalibration(); #endif defined (USE_FPGA) //配置射频内核 SMI 数据链接 IOCPortConfigureSet (IOID_12、RFC_PORT_RFC_GPO0、USC_PIC_OUTP_0、IOC_DIC_OUTPSIT_11);IOCOST_DIC_DIOR_DIOT_DIOT_DIOT_DIO0_TOP0 IOC_STD_INPUT); //配置射频内核 SMI 命令链接 IOCPortConfigureSet (IOID_10、IOC_IOCFG0_PORT_ID_RFC_SMI_CL_OUT、IOC_STD_OUTPUT); IOCPortConfigureSet (IOID_9、IOC_IOCFG0_PORT_ID_RFC_SMI_OUT、IOC_CL_ING_IN、IOCPort_Config_CL_CL_IN IOC_STD_INPUT); //配置射频内核跟踪器 IO IOCPortConfigureSet (IOID_8、IOC_PORT_RFC_TRC、IOC_STD_OUTPUT); #else //!use_FPGA #if defined (debug_sw_trace) //配置射频内核跟踪器 IO IOCPortConfigureSet (IOID_8、IOC_PORT_RFC_TRC、IOC_STD_OUTPUT | IOC_CURRENT_4mA | IOC_SLEW_ENABLE); #endif // debug_sw_trace #endif // use_fpga //创建 RTOS 队列以将配置文件中的消息发送到应用。 appMsgQueue = Util_constructQueue (&appMsg); //为内部周期事件创建单次时钟。 Util_constructClock (周期时钟、SimpleBLEPeripheral_clockHandler、 SBP_PERIOD_EVT_PERIOD、0、false、SBP_PERIOD_EVT); //设置 GAP GAP_SetParamValue (TGAP_CONN_PAUSE_PERUST_PERIOD、DEFAULT_CONN_PAUSE_PERIOUT); //设置 GAP 外设角色配置文件 { //对于所有硬件平台,设备在初始化时开始广播 uint8_t 初始化地址使能= true; //通过将此值设置为零,器件将在之后进入等待状态 //可发现30.72秒,并且不会再次进行广播 //直到启用程序设置回 true uint16_t advertOffTime = 0; uint8_t enableUpdateRequest = default_enable_update_request; uint16_t desedMinInterval = default_desed_min_CONN_interval; uint16_t desedMaxInterval = default_desed_MAX_CONN_INTERVAL; uint16_t desedSlaveLatency = default_desed_slave_latency; uint16_t desedConnTimeout = default_desed_CONN_TIMEOUT; //设置 GAP 角色参数 GAPRole_SetParameter (GAPROLE_Adverte_enabled、sizeof (uint8_t)、 初始化启用(&A); GAPRole_SetParameter (GAPROLE_GOOD_OFF_TIME、sizeof (uint16_t)、 advertOffTime (advertOffTime)(&D); GAPRole_SetParameter (GAPROLE_SCAN_RSP_DATA、sizeof (scanRspData)、 scanRspData); GAPRole_SetParameter (GAPROLE_adverted_data、sizeof (advertData)、advertData); GAPRole_SetParameter (GAPROLE_PARAM_UPDATE_ENABLE、sizeof (uint8_t)、 enableUpdateRequest (enableUpdateRequest)(enableUpdateRequest)); GAPRole_SetParameter (GAPROLE_MIN_CONN_INTERVAL、sizeof (uint16_t)、 需要最小间隔(&D); GAPRole_SetParameter (GAPROLE_MAX_CONN_INTERVAL、sizeof (uint16_t)、 指定最大间隔(&D); GAPRole_SetParameter (GAPROLE_SLAVE_DELUMMER、sizeof (uint16_t)、 希望从属延迟(&D); GAPRole_SetParameter (GAPROLE_TIMEOUT_MULTIER、sizeof (uint16_t)、 需要连接超时); } //设置 GGS_SetParameter ( GGS_DEVICE_NAME_ATT、GAP_DEVICE_NAME_LEN、attDeviceName) GAP 特性; //设置广播间隔 { uint16_t advInt = default_advertising_interval; GAP_SetParamValue (TGAP_LIM_DISC_ADV_INT_MIN、advInt); GAP_SetParamValue (TGAP_LIM_DISC_ADV_INT_MAX、advInt); GAP_SetParamValue (TGAP_GEN_DISC_ADV_INT_MIN、advInt); GAP_SetParamValue (TGAP_GEN_DISC_ADV_INT_MAX、advInt); } //设置 GAP 绑定管理 器{ uint32_t 密钥= 0;//密钥"000000" uint8_t pairMode = GAPBOND_Pairing_mode_wait_for_Req; uint8_t MIPTM = true; uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; uint8_t 绑定= true; GAPBondMgr_SetParameter (GAPBOND_DEFAULT_Passcode、sizeof (uint32_t)、 密钥); GAPBondMgr_SetParameter (GAPBOND_Pairing_mode、sizeof (uint8_t)、&pairMode); GAPBondMgr_SetParameter (GAPBOND_MITM_protection、sizeof (uint8_t)、&MIPTM); GAPBondMgr_SetParameter (GAPBOND_IO_Capabilities、sizeof (uint8_t)、&ioCap); GAPBondMgr_SetParameter (GAPBOND_BUSIONIND_ENABLED、sizeof (uint8_t)、&bonding); } //初始化 GATT 属性 GGS_AddService (GATT_ALL_SERVICES); // GAP GATTServApp_AddService (GATT_All_services);// GATT 属性 DevInfo_AddService (); //设备信息服务 #ifndef feature_OAD_ONCHIP SimpleProfile_AddService (GATT_All_services);//简单 GATT 配置文件 #endif //!feature_OAD_ONCHIP #ifdef feature_OAD void OAD_addService (); // OAD 配置文件 OAD_register (((oadTargetCBs_t *)&simpleBLEPeripheral_oadCBs); hOadQ = Util_constructQueue (&oadQ); #endif //feature_OAD #ifdef image_reset_addService (); #endif //image_constructQueue (&oadQ);#enerate 设置/feature_opiverate IP 配置文件特性/使其无效 uint8_t charValue1 = 1; uint8_t charValue2 = 2; uint8_t charValue3 = 3; uint8_t charValue4 = 4; uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN]={1、2、3、4、5}; SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR1、sizeof (uint8_t)、 charValue1); SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR2、sizeof (uint8_t)、 charValue2); SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR3、sizeof (uint8_t)、 charValue3); SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR4、sizeof (uint8_t)、 charValue4); SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR5、SIMPLEPROFILE_CHAR5_LEN、 charValue5); } //使用 SimpleGATTprofile SimpleProfile_RegisterAppCBs (&SimpleBLEPeripheral_simpleProfileCBs)注册回调; #endif //!Feature_OAD_ONCHIP System_printf ("Check \n"); dispHandle = Display_open (Display_Type_UART);dispF ("Check n"); if (dispHandle){ Display_print0 (dispHandle、0、0、"Hello SensorTag Serial!"); } System_printf ("dispHandle =%d\n"、dispHandle); //启动器件 void GAPRole_StartDevice (&SimpleBLEPeripheral_gapRoleCBs); //启动 Bond Manager void GAPBondMgr_Register (&simpleBLEPeripheral_BondMgrCBs); //使用 GAP 注册 HCI/主机消息 GAP_RegisterForMsgs ( GATT 实体);//自定义 BLE_Display (0);针对#BLE_0 (PLE_RETOOT_0)、PLE_RETOPLE_0)的 PLE_REPLE_REPTE_REPLEAD_REPONSE;//以显示#OBJT (PLE_REPLE_REPLE_REPLE_REPLE_0);//以 PLE_REPLE_REPLE_REPLETID (PLE_REPLE 0、0、"BLE 外设 B"); #endif // HAL_image_A #else Display_print0 (dispHandle、0、0、"BLE Peripheral"); #endif // feature_OAD } /********* *@fn SimpleBLEPeripheral_taskFxn * *@简单 BLE 外设的简要应用任务入口点。 * *@param a0、A1 -未使用。 * *@返回无。 // 静态空 SimpleBLEPeripheral_taskFxn (UARg a0、UARg A1) { //初始化应用 SimpleBLEPeripheral_init (); // 应用程序主循环(;) { Display_print0 (dispHandle、0、0、"测试测试测试\n"); //等待与调用线程关联的信号量。 //请注意、当发出信号时、与线程关联的信号量会发出信号 //消息在线程的消息接收队列中排队,或在何时排队 // iCall_signal ()函数被调用到信号量上。 iCall_errno errno = iCall_Wait (ICALL_TIMEOUT_FOREVAL); if (errno =ICALL_errno_Success) { iCall_EntityID dest; iCall_ServiceEnum src; iCall_HciExtEvt *pMsg =空; if (iCall_fetchServiceMsg (&src、&dest、 (void **)&pMsg)=ICALL_errno_Success) { uint8 safeToDealloc = true; IF (((src =ICALL_SERVICE_CLASS_BLE)&&(dest =self Entity)) { iCall_Stack_Event *pEvt =(iCall_Stack_Event *) pMsg; //首先检查 BLE 堆栈事件 if (pEvt->signature == 0xFFFF) { if (pEvt->EVENT_FLAG & SBP_CONN_EVT_END_EVT) { //尝试重新发送待处理的 ATT 响应(如果有) SimpleBLEPeripheral_sendAttRsp(); } } 其他 { //处理任务间消息 safeToDealloc = SimpleBLEPeripheral_processStackMsg ((iCall_HDR *) pMsg); } } if (pMsg && safeToDealloc) { iCall_freeMsg (pMsg); } } //如果 RTOS 队列不为空,则处理应用程序消息。 while (!Queue_empty (appMsgQueue)) { sbpEvt_t *pMsg =(sbpEvt_t *) Util_dequeueMsg (appMsgQueue); if (pMsg) { //处理消息。 SimpleBLEPeripheral_processAppMsg (pMsg); //从消息中释放空间。 iCall_free (pMsg); } } IF (事件和 SBP_Periode_EVT) { 事件&=~SBP_Periode_EVT; Util_startClock (周期时钟); //执行周期性应用任务 SimpleBLEPeripheral_performPeriodicTask(); } #ifdef Feature_OAD while (!Queue_empty (hOadQ)) { oadTargetWrite_t * oadWriteEvt = Queue_get (hOadQ); //识别新图像。 if (oadWriteEvt->event == OAD_WRITE_Identify_Req) { OAD_imgIdentifyWrite (oadWriteEvt->connHandle、oadWriteEvt->pData); } //写下一个块请求。 否则(oadWriteEvt->event =OAD_WRITE_BLOCK_REQ) { OAD_imgBlockWrite (oadWriteEvt->connHandle、oadWriteEvt->pData); } //自由缓冲区。 iCall_free (oadWriteEvt); } #endif //feature_OAD } } /********* *@fn SimpleBLEPeripheral_processStackMsg * *@简短地处理传入的堆栈消息。 * *@param pMsg -要处理的消息 * *@如果可以安全地取消分配传入消息、则返回 true、否则返回 false。 // 静态 uint8_t SimpleBLEPeripheral_processStackMsg (iCall_HDR *pMsg) { uint8_t safeToDealloc = true; switch (pMsg->event) { 案例 GATT_MSG_EVENT: //处理 GATT 消息 SAFeToDealloc = SimpleBLEPeripheral_processGATTMsg (((gattMsgEvent_t *) pMsg); 中断; 案例 HCI_GAP_EVENT_EVENT: { //处理 HCI 消息 switch (pMsg->status) { 案例 HCI_COMMAND_COMPLET_EVENT_CODE: //处理 HCI 命令完成事件 中断; 案例 HCI_BLE_hardware_error_event_code: { AssertHandler (HAL_assert_cause_hardware_error、0); } 中断; 默认值: 中断; } } 中断; 默认值: //不执行任何操作 break; } return (safeToDealloc); }/********* *@fn SimpleBLEPeripheral_processGATTMsg * @简短处理 GATT 消息和事件。 * *@如果可以安全地取消分配传入消息、则返回 true、否则返回 false。 // 静态 uint8_t SimpleBLEPeripheral_processGATTMsg (gattMsgEvent_t *pMsg) { //查看 GATT 服务器是否无法发送 ATT 响应 (如果(pMsg->HDR.status == blePending) { //没有 HCI 缓冲器可用。 让我们尝试重新传输响应 //发生下一个连接事件。 if (HCI_EXT_ConnEventNoticeCmd (pMsg->connHandle、self 实体、 SBP_CONN_EVT_END_EVT)=成功) { //首先释放任何待处理的响应 SimpleBLEPeripheral_freeAttsp (故障); //保持响应消息以重新传输 pAttRsp = pMsg; //尚未释放响应消息 返回(false); } } 否则、如果(pMsg->method =ATT_flow_CTRL_쟖 랸_event) { // ATT 请求-响应或指示-确认流量控制为 //违反。 所有后续 ATT 请求或指示将被丢弃。 //如果应用程序想要断开连接,将通知该应用程序。 //显示导致违规的消息的操作码。 Display_Print1 (dispHandle、5、0、"FC ined:%d"、pMsg->msg.flowCtrlEvt.opcode); } 否则、如果(pMsg->method =ATT_MTU_updated_event) { // MTU 大小已更新 Display_Print1 (dispHandle、5、0、"MTU 大小:$d"、pMsg->msg.mtuEvt.MTU); } //自由消息有效载荷。 仅用于 ATT 协议消息 GATT_BM_FREE (&pMsg->msg、pMsg->方法); //释放传入消息 返回是安全的(TRUE); } /********* *@fn SimpleBLEPeripheral_sendAttRsp * *@简短发送待处理的 ATT 响应消息。 * *@param none * *@return none */ static void SimpleBLEPeripheral_sendAttRsp (void) { //如果 (pAttRsp!= NULL) 、请查看是否有待处理的 ATT 响应要传输{ uint8_t status; //递增重发计数 rspTxRetry++; //尝试重新发送 ATT 响应,直到我们成功或 // ATT 客户端超时(30秒后)并断开连接。 status = GATT_SendRsp (pAttRsp->connHandle、pAttRsp->method、&(pAttRsp->msg)); if ((status!= blePending)&&(status!= MSG_buffer_no_avail)) { //禁用连接事件结束通知 HCI_EXT_ConnEventNoticeCmd (pAttRsp->connHandle、self 实体、0); //我们已完成响应消息 SimpleBLEPeripheral_freeAttsp (status); } 其他 { //继续重试 Display_Print1 (dispHandle、5、0、"RSP SEND RETRY:%d"、rspTxRetry); } } /********* *@fn SimpleBLEPeripheral_freeAttsp * *@简短的 Free ATT Response 消息。 * **@param status - Response transmit status * *@return none */ static void SimpleBLEPeripheral_freeAttRsp (uint8_t status) { //如果 (pAttRsp!= NULL)、请查看是否存在待处理的 ATT 响应消息 { //查看响应是否已成功发送 if (status == Success)(如果(状态==成功)) { Display_Print1 (dispHandle、5、0、"RSP Sent retry:%d"、rspTxRetry); } 其他 { //自由响应有效载荷 GATT_BM_FREE (&pAttRsp->msg、pAttRsp->method); Display_Print1 (dispHandle、5、0、"RSP 重试失败:%d"、rspTxRetry); } //自由响应消息 iCall_freeMsg (pAttRsp); //重置我们的全局变量 pAttRsp =空; rspTxRetry = 0; } /********* *@fn SimpleBLEPeripheral_processAppMsg * *@简要处理来自配置文件的传入回调。 * *@param pMsg -要处理的消息 * @返回无。 // 静态空 SimpleBLEPeripheral_processAppMsg (sbpEvt_t *pMsg) { switch (pMsg->HDR.event) { 案例 SBP_State_change_EVT: SimpleBLEPeripheral_processStateChangeEvt ((gaprole_states_t) pMsg-> HDR.state); 中断; 案例 SBP_CHAR_CHANGE_EVT: SimpleBLEPeripheral_processCharValueChangeEvt (pMsg->HDR.state); 中断; 默认值: //不执行任何操作。 中断; } /********* *@fn SimpleBLEPeripheral_stateChangeCB * *@GAP 角色的简短回调、指示角色状态更改。 * *@param newState - new state * *@return None。 */ static void SimpleBLEPeripheral_stateChangeCB (gaprole_states_t newState) { SimpleBLEPeripheral_enqueueMsg (SBP_State_Change_EVT、newState); } /********* *@fn SimpleBLEPeripheral_processStateChangeEvt * *@简要处理待处理的 GAP 角色状态更改事件。 * *@param newState - new state * *@return None。 */ static void SimpleBLEPeripheral_processStateChangeEvt (gaprole_states_t newState) { #ifdef plus_broadcaster static bool ConnfirstFlag = false; #endif // plus_broadcaster switch (newState) { 案例 GAPROLE_Started: { uint8_t ownAddress[B_ADDR_LEN]; uint8_t systemId[DevInfo_system_ID_LEN]; GAPRole_GetParameter (GAPROLE_BD_ADDR、ownAddress); //将6个字节的设备地址用于8个字节的系统 ID 值 SystemID[0]= ownAddress[0]; SystemID[1]= ownAddress[1]; SystemID[2]= ownAddress[2]; //将中间字节设置为零 SystemID[4]= 0x00; SystemID[3]= 0x00; //向上移动三个字节 SystemID[7]= ownAddress[5]; SystemID[6]= ownAddress[4]; SystemID[5]= ownAddress[3]; DevInfo_SetParameter (DevInfo_system_ID、DevInfo_system_ID_LEN、systemId); //显示设备地址 Display_print0 (dispHandle、1、0、Util_convertBdAddr2Str (ownAddress)); display_print0 (dispHandle、2、0、"已初始化"); } 中断; 案例 GAPROLE_advertising: Display_print0 (dispHandle、2、0、"广播"); break; #ifdef plus_broadcaster /*在断开连接后,PLUS_Broadcaster 中的设备将继续 *发送不可连接的广播并应发送此更改 向应用程序发送*状态。 然后在这里禁用这些功能、以便发送 *可以恢复可连接的广播。 * 案例 GAPROLE_advertising_NONCONN: { uint8_t advertEnabled = false; //禁用非连接的广播。 GAPRole_SetParameter (GAPROLE_ADV_NONCONN_ENABLED、sizeof (uint8_t)、 advertEnabled (advertEnabled)(&D); advertEnabled = true; //启用可连接广播。 GAPRole_SetParameter (GAPROLE_Adverte_enabled、sizeof (uint8_t)、 advertEnabled (advertEnabled)(&D); //重置下一个连接的标志。 firstConnFlag = false; SimpleBLEPeripheral_freeAttsp (bleNotConnected); } break; #endif //plus_broadcaster 案例 GAPROLE_Connected: { linkDBInfo_t linkInfo; uint8_t numActive = 0; Util_startClock (周期时钟); numActive = linkDB_NumActive(); //使用 numActive 确定最后一个的连接句柄 //连接 if ( linkDB_getinfo( numActive -1,&linkInfo )==成功) { Display_Print1 (dispHandle、2、0、"Num Conns:%d"、(uint16_t) numActive); Display_print0 (dispHandle、3、0、Util_convertBdAddr2Str (linkInfo.addr)); } 其他 { uint8_t peerAddress[B_ADDR_LEN]; GAPRole_GetParameter (GAPROLE_CONN_BD_ADDR、peerAddress); Display_print0 (dispHandle、2、0、"已连接"); Display_print0 (dispHandle、3、0、Util_convertBdAddr2Str (peerAddress)); } #ifdef PLUS_Broadcaster //仅在我们首次连接时打开此状态的广播 //否则、当我们从 connected 广播返回到该状态时 //我们将重新打开广播。 if (ConnfirstFlag = false) { uint8_t advertEnabled = false;//打开广播 //禁用可连接的广播。 GAPRole_SetParameter (GAPROLE_Adverte_enabled、sizeof (uint8_t)、 advertEnabled (advertEnabled)(&D); //对于非连接的广播,设置为 true。 advertEnabled = true; //启用非连接的广播。 GAPRole_SetParameter (GAPROLE_ADV_NONCONN_ENABLED、sizeof (uint8_t)、 advertEnabled (advertEnabled)(&D); firstConnFlag = true; } #endif // plus_broadcaster } 中断; 案例 GAPROLE_Connected ADV: Display_print0 (dispHandle、2、0、"连接广播"); 中断; 案例 GAPROLE_等待: Util_stopClock (周期时钟); SimpleBLEPeripheral_freeAttsp (bleNotConnected); Display_print0 (dispHandle、2、0、"已断开连接"); //清除剩余行 Display_clearLines (dispHandle、3、5); 中断; 案例 GAPROLE_WAITING_FACT_TIMEOUT: SimpleBLEPeripheral_freeAttsp (bleNotConnected); Display_print0 (dispHandle、2、0、"超时"); //清除剩余行 Display_clearLines (dispHandle、3、5); #ifdef PLUS_Broadcaster //重置下一个连接的标志。 firstConnFlag = false; #endif //#ifdef (PLUS_Broadcaster) 中断; 案例 GAPROLE_ERROR: Display_print0 (dispHandle、2、0、"Error"); 中断; 默认值: Display_Clearline (dispHandle、2); break; } //更新状态 //gapProfileState = newState; } #ifndef feature_OAD_ONCHIP /********* *@fn SimpleBLEPeripheral_charValueChangeCB * *@简单配置文件中指示特征的简短回调 * 值变化。 * *@param paramID -已更改值的参数 ID。 * *@返回无。 */ static void SimpleBLEPeripheral_charValue***ChangeCB (uint8_t paramID) { SimpleBLEPeripheral_enqueueMsg (SBP_char_change_evt、paramID); } #endif //!feature_OAD_ONCHIP /********* *@fn SimpleBLEPeripheral_processCharValueChangeEvt * *@简要处理暂挂的简单配置文件特征值更改 * 事件。 * *@param paramID -已更改值的参数 ID。 * *@返回无。 */ static void SimpleBLEPeripheral_processCharValueChangeEvt (uint8_t paramID) { #ifndef feature_OAD_ONCHIP uint8_t newValue; switch (paramID) { SIMPLEPROFILE_CHAR1案例: SimpleProfile_GetParameter (SIMPLEPROFILE_CHAR1、newValue); Display_Print1 (dispHandle、4、0、"Char 1:%d"、(uint16_t) newValue); 中断; SIMPLEPROFILE_CHAR3案例: SimpleProfile_GetParameter (SIMPLEPROFILE_CHAR3、newValue); Display_Print1 (dispHandle、4、0、"Char 3:%d"、(uint16_t) newValue); 中断; 默认值: //不应该到达这里! break; } #endif //!feature_OAD_ONCHIP } /********* *@fn SimpleBLEPeripheral_performPeriodicTask * *@brief 会执行周期性应用任务。 此函数被调用 * 每5秒(SBP_PERIOD_EVT_PERIOD)。 在此示例中、 * SimpleGATTProfile *中第三个特征的值 服务从配置文件中检索、然后复制到 *中 第四个特征的值。 * *@param 无。 * *@返回无。 // static void SimpleBLEPeripheral_performPeriodicTask (void) { #ifndef Feature_OAD_ONCHIP uint8_t valueToCopy; //如果 (SimpleProfile_GetParameter (SIMPLEPROFILE_CHAR3、&valueToCopy)= sucy、则调用以检索配置文件中第三个特征的值 //调用以设置配置文件中第四个特征的值。 //请注意,如果已收到第四个特征的通知 // GATT 客户端设备启用,然后将发送通知 //每次调用此函数。 SimpleProfile_SetParameter (SIMPLEPROFILE_CHAR4、sizeof (uint8_t)、 ValueToCopy); } #endif //!Feature_OAD_ONCHIP } #ifdef Feature_OAD /********* *@fn SimpleBLEPeripheral_processOadWriteCB * *@简要处理一个到 OAD 配置文件的写入请求。 * *@param 事件 -事件类型: * OAD_WRITE_Identify_Req * OAD_WRITE_BLOCK_REQ *@param connHandle -此请求的连接句柄来自。 *@param pData -指向数据的指针,用于处理和/或存储。 * *@返回无。 // void SimpleBLEPeripheral_processOadWriteCB (uint8_t 事件、uint16_t connHandle、 uint8_t *pData) { oadTargetWrite_t * oadWriteEvt = iCall_malloc (sizeof (oadTargetWrite_t)+\ sizeof (uint8_t)* OAD_packet_size); if (oadWriteEvt!= NULL) { oadWriteEvt->event = event; oadWriteEvt->connHandle = connHandle; oadWriteEvt->pData =(uint8_t *)(oadWriteEvt->pData + 1); memcpy (oadWriteEvt->pData、pData、OAD_packet_size); Queue_put (hOadQ、(Queue_Elem *) oadWriteEvt); //发布应用程序的信标。 Semaphore_post (sem); } 否则 { //无提示失败 。} } #endif //feature_OAD/ ********* *@fn SimpleBLEPeripheral_clockHandler * *@用于时钟超时的简短处理函数。 * *@param arg -事件类型 * @返回无。 */ static void SimpleBLEPeripheral_clockHandler (UARg arg) { //存储事件。 Events |= arg; //唤醒应用程序。 Semaphore_post (SEM); } /********* *@fn SimpleBLEPeripheral_enqueueMsg * *@brief 会创建一条消息并将该消息放入 RTOS 队列中。 * *@param 事件-消息事件。 *@参数状态-消息状态。 * *@返回无。 // 静态空 SimpleBLEPeripheral_enqueueMsg (uint8_t 事件、uint8_t 状态) { sbpEvt_t *pMsg; //创建消息的动态指针。 if (((pMsg = iCall_malloc (sizeof (sbpEvt_t)))) ){ pMsg->HDR.EVENT =事件; pMsg->HDR.state = state; //将消息排队。 Util_enqueueMsg (appMsgQueue、SEM、(uint8*) pMsg); } /********* (三 /
我目前完全不知道。 正如我说过的、Display 示例的工作没有问题。 为了我的最大能力、我已经检查了所有设置是否相同并实现了相同的代码、但我完全可以忽略某些内容。
您对这种情况的想法将不胜感激。
感谢您的持续帮助和支持
了解了当今预处理器的现状... 为什么从预处理器列表中删除 Display_disable_all 对于 Display_printf 以及如何执行该操作很重要。
Properties -> Build -> ARM Compiler -> Predefined Symbols 并删除了 Display_disable_all
不是原始问题的答案、而是足够好的答案。
感谢每个人的帮助!
Thom、您好!
不好! 我不确定 Display_disable_all 的历史记录是什么 以及为什么某些 BLE 示例具有它。 我将在下一个版本的 SimpleLink Academy 调试输出实验室中添加一条注意事项。 我将打开一个 JIRA TT、让项目中的自述文件也提及它(并给出完成该操作的原因)。
Todd