BlueNRG代码浏览

在这里定义设备名称、地址(但是实际地址好像每次复位后都是随机变化的一个不同的地址)。
这里定义了service-uuid characteristic-uuid
刚好跟使用BlueroothLE GATT 程序看到的最后两个 service-uuid characteristic-uuid 相同。


Main 函数代码结构:

判别有无User-Key 按键按下,如果按下,并且 BLE 已经连接了的话, acc-service 里面的 axes-X 轴的值加 200 ,并更新。
在更新acc-service 中,将 X Y Z 的值复制到 buff ,然后调用 aci_gatt_update_char_value 函数更新这个值。而底层协议栈更新之后,如果是 notify 权限,则发送 notification gatt-client ,也就是我们的手机上的 app 。这样就出现了旋转立方体的效果。



以下是使用TI的BLE-dongle并使用BLE-Device-Monitor记录的各种属性、service、characteristic
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <attributes>
  3.   <attribute>
  4.     <handle>1</handle>
  5.     <type>0x2800</type>
  6.     <mnemonic>GATT Primary Service Declaration</mnemonic>
  7.     <value></value>
  8.   </attribute>
  9.   <attribute>
  10.     <handle>2</handle>
  11.     <type>0x2803</type>
  12.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  13.     <value>20:03:00:05:2A</value>
  14.   </attribute>
  15.   <attribute>
  16.     <handle>3</handle>
  17.     <type>0x2A05</type>
  18.     <mnemonic>Service Changed</mnemonic>
  19.     <value></value>
  20.   </attribute>
  21.   <attribute>
  22.     <handle>4</handle>
  23.     <type>0x2902</type>
  24.     <mnemonic>Client Characteristic Configuration</mnemonic>
  25.     <value></value>
  26.   </attribute>
  27.   <attribute>
  28.     <handle>5</handle>
  29.     <type>0x2800</type>
  30.     <mnemonic>GATT Primary Service Declaration</mnemonic>
  31.     <value></value>
  32.   </attribute>
  33.   <attribute>
  34.     <handle>6</handle>
  35.     <type>0x2803</type>
  36.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  37.     <value>4E:07:00:00:2A</value>
  38.   </attribute>
  39.   <attribute>
  40.     <handle>7</handle>
  41.     <type>0x2A00</type>
  42.     <mnemonic>Device Name</mnemonic>
  43.     <value>42:6C:75:65:4E:52:47</value>
  44.   </attribute>
  45.   <attribute>
  46.     <handle>8</handle>
  47.     <type>0x2803</type>
  48.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  49.     <value>4E:09:00:01:2A</value>
  50.   </attribute>
  51.   <attribute>
  52.     <handle>9</handle>
  53.     <type>0x2A01</type>
  54.     <mnemonic>Appearance</mnemonic>
  55.     <value>02:00</value>
  56.   </attribute>
  57.   <attribute>
  58.     <handle>10</handle>
  59.     <type>0x2803</type>
  60.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  61.     <value>0E:0B:00:02:2A</value>
  62.   </attribute>
  63.   <attribute>
  64.     <handle>11</handle>
  65.     <type>0x2A02</type>
  66.     <mnemonic>Peripheral Privacy Flag</mnemonic>
  67.     <value>00</value>
  68.   </attribute>
  69.   <attribute>
  70.     <handle>12</handle>
  71.     <type>0x2803</type>
  72.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  73.     <value>0E:0D:00:03:2A</value>
  74.   </attribute>
  75.   <attribute>
  76.     <handle>13</handle>
  77.     <type>0x2A03</type>
  78.     <mnemonic>Reconnection Address</mnemonic>
  79.     <value>00:00:00:00:00:00</value>
  80.   </attribute>
  81.   <attribute>
  82.     <handle>14</handle>
  83.     <type>0x2803</type>
  84.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  85.     <value>0A:0F:00:04:2A</value>
  86.   </attribute>
  87.   <attribute>
  88.     <handle>15</handle>
  89.     <type>0x2A04</type>
  90.     <mnemonic>Peripheral Preferred Connection Parameters</mnemonic>
  91.     <value>00:00:00:00:00:00:00:00</value>
  92.   </attribute>
  93.   <attribute>
  94.     <handle>16</handle>
  95.     <type>0x2800</type>
  96.     <mnemonic>GATT Primary Service Declaration</mnemonic>
  97.     <value></value>
  98.   </attribute>
  99.   <attribute>
  100.     <handle>17</handle>
  101.     <type>0x2803</type>
  102.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  103.     <value>10:12:00:1B:C5:D5:A5:02:00:FC:8F:E1:11:4A:CF:A0:78:3E:E2</value>
  104.   </attribute>
  105.   <attribute>
  106.     <handle>18</handle>
  107.     <type>E23E78A0-CF4A-11E1-8FFC-0002A5D5C51B</type>
  108.     <mnemonic></mnemonic>
  109.     <value></value>
  110.   </attribute>
  111.   <attribute>
  112.     <handle>19</handle>
  113.     <type>0x2902</type>
  114.     <mnemonic>Client Characteristic Configuration</mnemonic>
  115.     <value>00:00</value>
  116.   </attribute>
  117.   <attribute>
  118.     <handle>20</handle>
  119.     <type>0x2803</type>
  120.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  121.     <value>12:15:00:1B:C5:D5:A5:02:00:36:AC:E1:11:4B:CF:80:1B:0A:34</value>
  122.   </attribute>
  123.   <attribute>
  124.     <handle>21</handle>
  125.     <type>340A1B80-CF4B-11E1-AC36-0002A5D5C51B</type>
  126.     <mnemonic></mnemonic>
  127.     <value>58:02:00:00:00:00</value>
  128.   </attribute>
  129.   <attribute>
  130.     <handle>22</handle>
  131.     <type>0x2902</type>
  132.     <mnemonic>Client Characteristic Configuration</mnemonic>
  133.     <value>00:00</value>
  134.   </attribute>
  135.   <attribute>
  136.     <handle>23</handle>
  137.     <type>0x2800</type>
  138.     <mnemonic>GATT Primary Service Declaration</mnemonic>
  139.     <value></value>
  140.   </attribute>
  141.   <attribute>
  142.     <handle>24</handle>
  143.     <type>0x2803</type>
  144.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  145.     <value>02:19:00:1B:C5:D5:A5:02:00:E3:A9:E2:11:77:E4:20:55:2E:A3</value>
  146.   </attribute>
  147.   <attribute>
  148.     <handle>25</handle>
  149.     <type>A32E5520-E477-11E2-A9E3-0002A5D5C51B</type>
  150.     <mnemonic></mnemonic>
  151.     <value>18:01</value>
  152.   </attribute>
  153.   <attribute>
  154.     <handle>26</handle>
  155.     <type>0x2904</type>
  156.     <mnemonic>Characteristic Presentation Format</mnemonic>
  157.     <value></value>
  158.   </attribute>
  159.   <attribute>
  160.     <handle>27</handle>
  161.     <type>0x2803</type>
  162.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  163.     <value>02:1C:00:1B:C5:D5:A5:02:00:0B:84:E2:11:8B:E4:80:C4:20:CD</value>
  164.   </attribute>
  165.   <attribute>
  166.     <handle>28</handle>
  167.     <type>CD20C480-E48B-11E2-840B-0002A5D5C51B</type>
  168.     <mnemonic></mnemonic>
  169.     <value>20:87:01</value>
  170.   </attribute>
  171.   <attribute>
  172.     <handle>29</handle>
  173.     <type>0x2904</type>
  174.     <mnemonic>Characteristic Presentation Format</mnemonic>
  175.     <value>0F:FB:80:27:00:00:00</value>
  176.   </attribute>
  177.   <attribute>
  178.     <handle>30</handle>
  179.     <type>0x2803</type>
  180.     <mnemonic>GATT Characteristic Declaration</mnemonic>
  181.     <value>02:1F:00:1B:C5:D5:A5:02:00:73:A0:E2:11:8C:E4:60:0B:C5:01</value>
  182.   </attribute>
  183.   <attribute>
  184.     <handle>31</handle>
  185.     <type>01C50B60-E48C-11E2-A073-0002A5D5C51B</type>
  186.     <mnemonic></mnemonic>
  187.     <value>12:02</value>
  188.   </attribute>
  189.   <attribute>
  190.     <handle>32</handle>
  191.     <type>0x2904</type>
  192.     <mnemonic>Characteristic Presentation Format</mnemonic>
  193.     <value>06:FF:00:27:00:00:00</value>
  194.   </attribute>
  195. </attributes>
复制代码
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值