---
# System prepended metadata

title: m001 開機與配對

---

# m001 開機與配對

### step 1
* 檢查 pairingFile.txt 是否存在 , 

如果不存在 開機進入配對模式

如果存在 開機進入 正常模式


### 配對模式 
UUID: 
write:fc289e35-ad28-48c2-a4ad-d342ba635ac2
Read:2720af87-dc41-4ef7-b16d-d0014390e595
#### device 
藍芽廣播. "ROEHL M001" (這名字尚未定案)
step 0. mobile BLE pairing

step 1. mobile get productId,deviceName from "device Bluetooth boardcast name"

Step 2. mobile send

{"SSID":"String","Password":"String","PSK":"String"}
Step3. mobille read “success msg”

Bluetooth process done
![](https://i.imgur.com/wOkW81f.png)

#### for firmware notes

* 順序最高1:裝置長壓按鈕5sec進入配對模式 -> MQTT 主程式執行中 




```
pairing.key 內容:
{"SSID":"String","Password":"String","PSK":"String"}
```

* bluetooh 啟動後 -> Read CHARACTERISTIC_UUID  setvalue({productid}{devicename})    (mobile self)read it
after read , send data to write CHARACTERISTIC_UUID -> device _BLECharacteristicCallbacks _onWrite () -> Characteristic->getValue(); device get {ssid....}  

device after get {...}  save pairing.key file
```
pCharacteristic->setValue("X5TVRIJ59A000002");
```


* if (Internet Pass) -> report ("success ")to Mobile .
    *    waiting "reset" or (waiting time out)for reboot , waiting time = 500 sec 



ex1 : {"SSID":"asdsda","Password":,"PSK":}  --> SSID
ex2 : {"SSID":"asdsda","Password":"asddas","PSK":}-->SSID/PW
ex3 : {"SSID":"asdsda","Password":"asddas","PSK":"aasd"}--> SSID/PW/PSK




