首页 > 其他分享 >CH58X/CH57X/V208的Broadcaster(广播者)例程讲解

CH58X/CH57X/V208的Broadcaster(广播者)例程讲解

时间:2022-11-05 15:24:20浏览次数:105  
标签:Default CH57X GAPROLE 例程 Write Read Broadcaster Size define

在对ble进行应用的时候,每个用户的需求可能不尽相同。这里着重介绍从机Broadcaster例程,只广播不连接。

使用该例程时可以在手机使用APP上对Broadcaster进行调试。

安卓端在应用市场搜索BLE调试助手下载使用,使用时要开启提示所需开启的权限。

 将Broadcaster例程烧录到DEMO板中。

 

烧录后发现一个蓝牙名称为abc的设备没有connect(连接)的选项,只能广播我无法连接。

接下来主要的程序拆分讨论:相对于peripheral例程,Broadcaster是比较精简的。这里直接从扫描应答包开始讨论,在APP上我们看到设备的是名称是abc,对比一下peripheral的名称为Simple Peripheral。

 

 

此时我们应该会有个疑问Broadcaster扫描应答包中的名称应该是Broadcaster,为什么APP上显示的是abc呢?

 

 这样就可以解释为什么设备名称不是Broadcaster而是abc,这个例程只有广播的功能,所以扫描应答包的设备名是不会显示出来的。

 

 其中对 GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable);进行更多的讨论

/*-------------------------------------------------------------------
 * FUNCTIONS - GAPRole API
 */
/**
 * @brief   Set a GAP Role parameter.
 *
 * @note    You can call this function with a GAP Parameter ID and it will set a GAP Parameter.
 *
 * @param   param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
 * @param   len - length of data to write
 * @param   pValue - pointer to data to write.  This is dependent on the parameter ID and
 *                   WILL be cast to the appropriate data type (example: data type of uint16_t
 *                   will be cast to uint16_t pointer).
 *
 * @return  SUCCESS or INVALIDPARAMETER (invalid paramID)
 */
extern bStatus_t GAPRole_SetParameter( uint16_t param, uint16_t len, void *pValue );
GAPRole_SetParameter后的三个参数值分别是配置文件参数 ID、要写入的数据长度、指向要写入的数据的指针。
配置文件参数在lib文件里。
#define GAPROLE_PROFILEROLE                     0x300  //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8_t.
#define GAPROLE_IRK                             0x301  //!< Identity Resolving Key. Read/Write. Size is uint8_t[KEYLEN]. Default is all 0, which means that the IRK will be randomly generated.
#define GAPROLE_SRK                             0x302  //!< Signature Resolving Key. Read/Write. Size is uint8_t[KEYLEN]. Default is all 0, which means that the SRK will be randomly generated.
#define GAPROLE_SIGNCOUNTER                     0x303  //!< Sign Counter. Read/Write. Size is uint32_t. Default is 0.
#define GAPROLE_BD_ADDR                         0x304  //!< Device's Address. Read Only. Size is uint8_t[B_ADDR_LEN]. This item is read from the controller.
#define GAPROLE_ADVERT_ENABLED                  0x305  //!< Enable/Disable Advertising. Read/Write. Size is uint8_t. Default is TRUE=Enabled.
#define GAPROLE_ADVERT_DATA                     0x306  //!< Advertisement Data. Read/Write. Max size is B_MAX_ADV_EXT_LEN. Default to all 0.
#define GAPROLE_SCAN_RSP_DATA                   0x307  //!< Scan Response Data. Read/Write. Max size is B_MAX_ADV_EXT_LEN. Defaults to all 0.
#define GAPROLE_ADV_EVENT_TYPE                  0x308  //!< Advertisement Type. Read/Write. Size is uint8_t.  Default is GAP_ADTYPE_ADV_IND.
#define GAPROLE_ADV_DIRECT_TYPE                 0x309  //!< Direct Advertisement Address Type. Read/Write. Size is uint8_t. Default is ADDRTYPE_PUBLIC.
#define GAPROLE_ADV_DIRECT_ADDR                 0x30A  //!< Direct Advertisement Address. Read/Write. Size is uint8_t[B_ADDR_LEN]. Default is NULL.
#define GAPROLE_ADV_CHANNEL_MAP                 0x30B  //!< Which channels to advertise on. Read/Write Size is uint8_t. Default is GAP_ADVCHAN_ALL
#define GAPROLE_ADV_FILTER_POLICY               0x30C  //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8_t. Default is GAP_FILTER_POLICY_ALL.
#define GAPROLE_STATE                           0x30D  //!< Reading this parameter will return GAP Peripheral Role State. Read Only. Size is uint8_t.
#define GAPROLE_MAX_SCAN_RES                    0x30E  //!< Maximum number of discover scan results to receive. Default is 0 = unlimited.
#define GAPROLE_MIN_CONN_INTERVAL               0x311  //!< Minimum Connection Interval to allow (n * 1.25ms).  Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16_t. Default is 7.5 milliseconds (0x0006).
#define GAPROLE_MAX_CONN_INTERVAL               0x312  //!< Maximum Connection Interval to allow (n * 1.25ms).  Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16_t. Default is 4 seconds (0x0C80).
// v5.x
#define GAPROLE_PHY_TX_SUPPORTED                0x313  //!< The transmitter PHYs that the Host prefers the Controller to use.Default is GAP_PHY_BIT_ALL
#define GAPROLE_PHY_RX_SUPPORTED                0x314  //!< The receiver PHYs that the Host prefers the Controller to use.Default is GAP_PHY_BIT_ALL
#define GAPROLE_PERIODIC_ADVERT_DATA            0x315  //!< Periodic advertisement Data. Read/Write. Max size is B_MAX_ADV_PERIODIC_LEN. Default to all 0.
#define GAPROLE_PERIODIC_ADVERT_ENABLED         0x316  //!< bit0:Enable/Disable Periodic Advertising. Read/Write. Size is uint8_t. Default is FALSE=Disable.
                                                       //!< bit1:Include the ADI field in AUX_SYNC_IND PDUs

这段代码为TMOS事件,TMOS的讲解可以参照这篇博客WCH TMOS用法详解 - debugdabiaoge - 博客园 (cnblogs.com)

广播流程与状态函数,

 

 

 

 GAPROLE_STARTED的定义可以在lib库中看到

#define GAPROLE_STATE_ADV_MASK             (0xF)    //!< advertising states mask
#define GAPROLE_STATE_ADV_SHIFT            (0x0)    //!< advertising states shift
#define GAPROLE_INIT                        0       //!< Waiting to be started
#define GAPROLE_STARTED                     1       //!< Started but not advertising
#define GAPROLE_ADVERTISING                 2       //!< Currently Advertising
#define GAPROLE_WAITING                     3       //!< Device is started but not advertising, is in waiting period before advertising again
#define GAPROLE_CONNECTED                   4       //!< In a connection
#define GAPROLE_CONNECTED_ADV               5       //!< In a connection + advertising
#define GAPROLE_ERROR                       6       //!< Error occurred - invalid state

这只是最基础的讨论,如有问题请指正!

 如转载请标明出处!文章可能被无良网站搬运。某些网站拿着别人的文章写着“我的编程学习分享”。

禁止写着我的编程学习分享的网站转载。

 

标签:Default,CH57X,GAPROLE,例程,Write,Read,Broadcaster,Size,define
From: https://www.cnblogs.com/frontier/p/16854694.html

相关文章

  • 编译gRPC相关示例程序,undefined reference to `deflateInit2_'等相关错误解决
    编译gRPC相关示例程序时,出现如下链接错误:/home/suph/.local/lib/libgrpc.a(message_compress.cc.o):Infunction`zlib_compress(grpc_slice_buffer*,grpc_slice_buffer*......
  • CH573/579/582 ADC例程介绍
    在adc的例程中共有六种AD测量,1、温度测量,2、单通道测量,3、DMA单通道测量,4、差分通道测量,5、触摸按键测量,6、中断方式单通道测量,接下来我们逐一描述。一、温度测量首先调......
  • Halcon入门之必看例程
    学习halcon例程是入门halcon的一种很好的方法,初学者尤其应该关注例程中处理问题的思路。以下是作者认为初入门时必看的例程名称,大家根据名称自行查找。......
  • 例程清单之 TI-DSP
    专栏一裸机TIF28335型TI-TMS320F例程(0)工程创建TI-TMS320F例程(1)点灯TI-TMS320F例程(2)流水灯TI-TMS320F例程(3)按键扫描输入TI-TMS320F例程(4)内部定时器0驱动......
  • 例程清单之 Altera-FPGA
    XilinxS6型例程【Verilog版|VHDL版】(0)工程创建例程【Verilog版|VHDL版】(1)xx例程【Verilog版|VHDL版】(2)xx例程【Verilog版|VHDL版】(3)xx例程【Verilog版......
  • 1490_TC275_UART_shell例程测试
    前面我已经测试了UART的简单例子,并且还修改了PIN脚通过Arduino来读取了串口信息。这是一个比较简单的监控方式,只需要一个PIN就能够给我提供printf打印功能。而这样的工具对......
  • CH573蓝牙主机(Central)例程讲解(主机功能流程介绍)
    蓝牙主机,顾名思义,就是一个蓝牙主设备,与从机建立连接进行通信,可以接收从机通知,也可以给从机发送信息,可将Central例程和Peripheral例程结合使用。蓝牙主机例程的工作流程大......
  • 基于V7的emWin多屏显示方案模板,同时驱动LCD和OLED例程
    说明:1、多屏驱动跟多图层驱动是类似的,可以使用函数GUI_SelectLayer做切换选择。2、为了避免OLED闪烁问题,创建一个128*64bit的显存空间,然后使用emWin的GUI_TIMER_Create创建......
  • ISP-55e0-WCH 用于 CH55x、CH57x 和 CH32Fx 的 ISP 闪存工具
    该工具旨在通过USB在Linux上通过USB闪存WinChipHeadCH55x/CH57x/CH32Fx系列,例如CH551、CH552、CH554、CH559、CH579。当设置为ISP模式时,芯片创建一个4348:55......
  • Android闪屏示例程序
     用过手机QQ的基本上都知道,刚启动程序时候会在一个界面停留一会,按任意键的就直接跳过,这就是所谓的闪屏。那么,在Android中怎样实现这样的效果呢? 1、新建一个Android项目,命......