Wen Wu's notes

technical record


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

软件工程

发表于 2019-07-21 更新于 2019-08-04 阅读次数: 评论数:

软件工程就是努力交付加上与客户斗智斗勇的一个过程。

软件需求铁三角

需求与开发

Bluetooth Topology

发表于 2019-07-17 分类于 蓝牙 阅读次数: 评论数:

BR/EDR Topology

BR/EDR Topology

LE Topology

LE Topology

Google Fast Pair

发表于 2019-07-13 分类于 蓝牙 阅读次数: 评论数:

官网规范
由于蓝牙设备在使用上有配对的流程,对于没有UI的设备来说,非常的不方便或是不安全。像Apple的Airpod,只要打开盒子,Apple的手机自动就弹出画面,只要点击一下就完成配对,非常的方便。
所以Google也在Android上搞了一个类似的东西,叫做Fast Pair。目前前几名的蓝牙大佬已经支持了。
本文就介绍Google Fast Pair (GFPS) 的基本原理。

基本原理

首先厂商需要到Nearby Devie注册自己的支持Google Fast Pair的设备,Nearby Device会分配Modle ID 和public key 及private key给该设备。
设备端通过BLE advertising广播自己的身份信息,当手机端发现搜索到的广播信息里表面设备支持GFPS,而且能认出该设备广播的modle ID的时候,就发起BLE连线到该设备,设备端发送其BR/EDR地址给手机,发送的数据是加密过的,手机拿到地址后发起BR/EDR连线,触发配对等流程,等BR/EDR连线都完成后,BLE连线就断开,整个Fast pair流程就结束。
整个过程,只有手机在发现支持GFPS的设备的时候,询问用户是否要连线,用户只要点击一下就行。

技术细节

角色定义

Seeker:手机端

Provider:设备端

1. 设备要首先要到Google nearby device去注册,这样Android才能识别出来。

设备的TX power设定有讲究

2. Power设定应该比较小,目标是离SP 1m内可被搜到.Google建议的设定方法:

The best way to determine the value is to measure the actual output of the device using an Android phone at 1 meter away, and then add 41 dBm to that. 41 dBm is the average signal strength loss that occurs over 1 meter.
Tx power 可以设定在广播包内,也可以设定在设备注册阶段就添上。
如果是在设备注册时就添上了Tx power的话,那所有的广播包都应该用这个Tx Power

3. 关于Key

  1. 反偷听的Public key 和private key(Anti-Spoofing Public/Private Key Pair)
    Private Key是 256bits,建议保存在安全区域,避免泄露出去
    Public Key在Seeker端才用得到
  2. Account Key list
    Account key是为了让Seeker能识别出来这个key是属于某个google账号的。

4.关于Advertising

在BR/EDR是discoverable时的Advertising设定:
  1. 在广播包中要加入24bit module ID
  2. Advertising Inerval <= 100ms
  3. 广播时要使用RPA address
  4. Payload里要包含GFPS的service UUID:0xFE2C
    在BR/EDR是non-discoverable时的Advertising设定
  5. 在广播包里加入 Account Key,这样Seeker在发现Provider有属于他认识的Account时,可以直接开始Fast Pair
  6. Advertising Interval <= 240ms
  7. 广播时也要用RPA地址
  8. Pay load要包含 GFPS的Service UUID 和 Account key list
  9. Account Key Filter
    为了让Seeker能尽快识别出Provider的广播包里是否有Seeker认识的Account,Provider对Account Key List计算出一个Key filter,Seeker能根据这个filter很快识别出是否有他关心的Account,从而决定是否要发起连线。
    这个算法的细节后续再加进来。

5. GATT Service

5.1 必须有GFPS Service
Service UIID
Fast Pair Service 0xFE2C
单元格 单元格

该Serviceyou如下的Charicterristic

Fast Pair Service characteristic Encrypted Permissions UUID
Key-based Pairing No Write and notify 0x1234
Passkey No Write and notify 0x1235
Account Key No Write 0x1236
5.2 ATT MTU Size Negotiation

MTU 的size 应该是83,23 也是可以的。

5.3 Characteristic: Key-based Pairing

Provider和Seeker基于一把private key,每次出发pair,public key/private key pair都应该不一样

5.4 Data format

Octet Data type Description Value Mandatory?
0 - 1 uint128 Encrypted Request varies Mandatory

16 - 79 |Public Key|varies|Optional|

常用的git命令

发表于 2019-07-10 分类于 GIT 阅读次数: 评论数:

介绍git原理的不错的文章: git from inside out

  1. git log —pretty=oneline
  2. git log -1
  3. git rev-parse —git-dir #show the .git folder name
  4. git add . git add filename git add all git add . -A
  5. git commit -s
  6. git commit -m “msg”
  7. git commit —amend # add the current file to the previous change list
  8. git push
  9. git bisect 是用二分法协助RD查找是哪笔check-in导致的错误的,请参考
  10. git diff 文件格式说明,link
  11. git diff HEAD — readme.txt
  12. git reset —hard HEAD^ 用remote端最新code盖掉index区域的改动(已经add到index的改动)
  13. git reset —hard 1094a 指定回到某个版本
  14. git cherry-pick
  15. git reflog 查找使用过的git command

    Mac01:BlueShell wnnwoo$ git reflog
    894474c (HEAD -> master) HEAD@{0}: reset: moving to HEAD^
    fcdea80 (origin/master) HEAD@{1}: commit: fix build error
    894474c (HEAD -> master) HEAD@{2}: commit: update basic operation
    94e2258 HEAD@{3}: commit: Run the scheme testing
    f305bac HEAD@{4}: commit: add generics test code
    4acfba7 HEAD@{5}: commit: Add error handle

  16. git checkout — readme.txt 丢弃工作区的改动
  17. git reset HEAD readme.txt 暂存区的修改回退到工作区
  18. git diff > abc.diff
  19. git apply abc.diff

control + r # search the history command

当呼吸化为空气

发表于 2019-07-10 更新于 2019-09-17 阅读次数: 评论数:

医生的职责是把铁拐修好,让病人可以去他们想去的地方。
如果是一大碗悲剧,最好一勺一勺的喂。很少有病人要求一口气吃完,大多数都需要时间去消化。
背负起别人的十字架,你总有时候会被重压压垮。
我看到自己皮囊之下瘦骨嶙峋,像行走的X光片。
展望无限广阔的未来,我看到的不是寂静无人的空荡荒原,而是更简单纯粹的东西:一页我将继续书写的白纸。

Mark down 语法记录

发表于 2019-07-09 更新于 2021-01-02 分类于 Markdown 阅读次数: 评论数:

一、标题

在想要设置为标题的文字前面加#来表示,一个#是一级标题,二个#是二级标题,以此类推。支持六级标题。

注:标准语法一般在#后跟个空格再写文字。

这是一级标题

这是二级标题

这是三级标题

这是四级标题

这是五级标题
这是六级标题

二、字体

要加粗的文字左右分别用两个*号包起来
要倾斜的文字左右分别用一个*号包起来
要倾斜和加粗的文字左右分别用三个*号包起来
要加删除线的文字左右分别用两个~~号包起来

这是加粗的文字
这是倾斜的文字`
这是斜体加粗的文字
这是加删除线的文字

三、引用

在引用的文字前加>即可。引用也可以嵌套,如加两个>>三个>>>n个… 貌似可以一直加下去

示例:

这是引用的内容

这是引用的内容

这是引用的内容

四、分割线

三个或者三个以上的 - 或者 * 都可以。
示例:

—-



五、图片

语法:
!图片alt

图片alt就是显示在图片下面的文字,相当于对图片内容的解释。
图片title是图片的标题,当鼠标移到图片上时显示的内容。title可加可不加

示例:
BR/EDR packet type

插入本地图片需要修改主题_config.yml配置文件post_asset_folder项为true,使用插件达到插入本地图片,在根目录输入如下命令安装:

$ npm install hexo-asset-image —save

new 一篇博客时/source/_posts文件夹内除了xxxx.md文件还有一个同名的文件夹,把图片放到里面即可.
最后在xxxx.md中想引入图片时,先把图片复制到xxxx这个文件夹中,然后只需要在xxxx.md中按照markdown的格式引入图片:![你想输入的替代文字](xxxx\/图片名.jpg)

六、超链接

语法:
[超链接名](超链接地址 “超链接title”) title可加可不加

示例:
[简书](http://jianshu.com)
[百度](http://baidu.com)

如果链接的最后一个字符是右括号 ),会有转义的问题,可以参考这个link Symposium(Plato)

注:Markdown本身语法不支持链接在新页面中打开,貌似简书做了处理,是可以的。别的平台可能就不行了,如果想要在新页面中打开的话可以用html语言的a标签代替。
\超链接名\</a>

示例
\wnnwoo\</a>
wnnwoo

七、列表

无序列表

语法:
无序列表用 - + * 任何一种都可以

  • 列表内容
  • 列表内容
  • 列表内容

注意:- + * 跟内容之间都要有一个空格

有序列表

语法:数字加点,序号与内容之间要有空格

  1. 列表内容
  2. 列表内容
  3. 列表内容

八、表格

语法:
表头|表头|表头
|—-|:—:|—-:|
内容|内容|内容
内容|内容|内容

第二行分割表头和内容。

  • 有一个就行,为了对齐,多加了几个文字默认居左
    -两边加:表示文字居中
    -右边加:表示文字居右
    注:原生的语法两边都要用 | 包起来。此处省略

示例:

姓名 技能 排行
刘备 哭 大哥
关羽 打 二哥
张飞 骂 三弟

九、代码

语法:
单行代码:代码之间分别用一个反引号包起来
`代码内容`

代码块:代码之间分别用三个反引号包起来,且两边的反引号单独占一行
(```)
代码…
代码…
代码…
(```)

示例:
单行代码
create database hero;

代码块

1
2
3
4
function fun(){
echo "这是一句非常牛逼的代码";
}
fun();

十、流程图

  1. 安装 flowchat 插件
    1
    npm install --save hexo-filter-flowchart

语法,请参考官网

十一、时序图

这里介绍美人鱼Mermaid的sequence chart

  1. 安装插件

    1
    npm install hexo-filter-mermaid-diagrams
  2. 配置theme下的config,将/themes/next/_config.yml内mermaid模块enable为true

    1
    2
    3
    4
    5
    6
    7
    # Mermaid tag
    mermaid:
    enable: true
    # Available themes: default | dark | forest | neutral
    theme: forest
    cdn: //cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js
    #cdn: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js
  3. 如果#2后还不起作用,那么配置博客根目录下的 _config.yml,在最后添加

    1
    2
    3
    4
    5
    6
    # mermaid chart
    mermaid: ## mermaid url https://github.com/knsv/mermaid
    enable: true # default true
    version: "7.1.2" # default v7.1.2
    options: # find more api options from https://github.com/knsv/mermaid/blob/master/src/mermaidAPI.js
    #startOnload: true // default true
  4. 编辑/themes/next/layout/_partials/footer.swig,在最后添加如下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    {% if theme.mermaid.enable %}
    <script src='https://unpkg.com/mermaid@{{ theme.mermaid.version }}/dist/mermaid.min.js'></script>
    <script>
    if (window.mermaid) {
    mermaid.initialize({{ JSON.stringify(theme.mermaid.options) }});
    }
    </script>
    {% endif %}
  5. 如果不奏效的话,把blog/_config.yml中的external_link设置为false和设置为true都试下.

  6. 完成前5步后,hexo g, hexo s还是不起作用,后来hexo clean之后再hexo g, hexo s,终于可以看到效果了

hexo 常用命令

发表于 2019-07-08 更新于 2019-10-03 分类于 Hexo 阅读次数: 评论数:

1. 生成网站

hexo g

2. 启动本地web service

hexo s

3. 推送到 git

hexo d
在推送前要在 _config.xml中配置好git地址

deploy:
type: git
repository: https://github.com/wnnwoo/wnnwoo.github.io.git
branch: master

4. 插入图片,可参考官网说明

_config.xml的post_asset_folder:设置为true
npm install hexo-asset-image —save

如果遇到类似下面的问题

Mac01:wnnwoo.github.io wnnwoo$ npm install hexo-asset-image —save
npm WARN babel-eslint@10.0.2 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.

  • hexo-asset-image@1.0.0
    updated 1 package and audited 9303 packages in 15.824s
    found 4 vulnerabilities (2 low, 2 high)
    run npm audit fix to fix them, or npm audit for details

是因为有版本不兼容的问题,执行下面的语句就可以了。

npm install -g npm

运行hexo n “file name”来生成md博客时,会在_post目录下看到一个与博客同名的文件夹
可以用下面的几个方法来引入图片,
不过我自己试的时候,总是显示不出来图片

4.1 ![你想要输入的替代文字](xxxx\/图片名.jpg)

4.2 \{ \% asset_img example.jpg This is an example image \% \}

4.3 ![你想要输入的替代文字](图片URL)

无奈,我用4.1 和4.2 都不行,只好购买阿里云,显示cloud上的图片是没问题的。

5.生成“分类”页并添加tpye属性

hexo new page categories
成功后会提示

INFO Created: ~/Documents/blog/source/categories/index.md
根据上面的路径,找到index.md这个文件,打开后默认内容是这样的:

1
2
3
4
---
title: 文章分类
date: 2017-05-27 13:47:40
---

添加type: “categories”到内容中,添加后是这样的:

1
2
3
4
5
---
title: 文章分类
date: 2017-05-27 13:47:40
type: "categories"
---

保存并关闭文件,打开其他markdown文件,然后加入categories,之后hexo就会自动生出来categories。

1
2
3
4
5
6
---
title: 鱼王
date: 2017-05-26 12:12:57
categories:
- 阅读
---

Google Bisto

发表于 2019-07-01 更新于 2019-07-13 阅读次数: 评论数:

AMA(Amazon Mobile Accessory)

发表于 2019-06-13 更新于 2019-07-13 阅读次数: 评论数:

bluetooth architecture, General description

发表于 2019-06-12 更新于 2019-07-21 阅读次数: 评论数:

Bluetooth wireless technology

  1. Basic Rate(BR)
    1. Enhanced Date Rate
    2. Alternertive Media Access Control (MAC)
    3. Physical(PHY) layer extensions
  2. Low Energy(LE)

Bluetooth Core System

  1. Host
  2. one or more Controller: primary Controllers and secondary Controllers
    BR/EDR controller:
    Radio,
    Baseband,
    Link Manager,
    HCI
    BLE Controller
    LE PHY
    Link Layer
    HCI

BR/EDR Overview

  1. Piconet
  2. Frequency hopping
  3. Physical channel: sub-divided into time units known as slots, TDD
    physical channel -> physical link -> logical transport -> logical link -> L2CAP channel

    The physical link is used as a transport for one or more logical links that support unicast synchronous, asynchronous and isochronous traffic, and broadcast traffic. Traffic on logical links is multiplexed onto the physical link by occupying slots assigned by a scheduling function in the resource manager.

  4. LMP,A control protocol for the baseband and physical layers is carried over logical links in addition to user data
  5. Connectionless Slave Broadcast devices

LE Overview

  1. PHY
    1M:
    1M Coded:
     coding scheme:(where S is the number of symbols per bit.)
         s=2: 2 symbols represent 1 bit, the speed is 500Kb/s
         s=8: 8 symbols represent 1 bit, the speed is 125Kb/s
    
    2M:
  2. 40 physical channel, 2M for 1 channel
  3. Events:The physical channel is sub-divided into time units known as events
    4 types events: Advertising, Extended Advertising, Periodic Advertising, and Connection events

    In connection events, channel hopping occurs at the start of each connection event. Within a connection event, the master and slave alternate sending data packets using the same data PHY channel. The master initiates the beginning of each connection event and can end each connection event at any time.

  4. Physical channel:

    The advertising and periodic physical links provide a unidirectional packet transport from the advertiser to a potentially unlimited number of scanners or initiators.

  5. Link Layer Protocol(LL), A control protocol for the link and physical layers is carried over logical links in addition to user data
  6. L2CAP:
    fregmentation and de-fregmentation
    multiplex and de-multiplex
    two Fixed channel: SMP and ATT.
  7. LE Radio: AoA, AoD

Question 1

Why the modem of BR is 1Mb/s, but the date rates is 721.2 kb/s?

The Basic Rate system offers synchronous and asynchronous connections with data rates of 721.2 kb/s for Basic Rate, 2.1 Mb/s for Enhanced Data Rate and high speed operation up to 54 Mb/s with the 802.11 AMP.
2DH5 / 6 slot
Question.2

Synchronization Train 是什么?

A series of packets transmitted on a set of fixed fre- quencies that deliver sufficient information for a receiv- ing device to start receiving corresponding Connectionless Slave Broadcast packets or to recover the current piconet clock after missing a Coarse Clock Adjust.

1…78910

Wen Wu

I'm a bluetooth Host and Controller developer
94 日志
24 分类
45 标签
© 2025 Wen Wu
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Gemini v7.2.0