การติดตั้งแบบเนทีฟ

ดูแหล่งข้อมูลใน GitHub

รับรหัส OTBR

ใน Raspberry Pi

  1. ติดตั้ง Git โดยทำดังนี้

    sudo apt install git
    

  2. โคลน ot-br-posix จาก GitHub โดยทำดังนี้

    git clone --depth=1 https://github.com/openthread/ot-br-posix
    

สร้างและติดตั้ง OTBR

OTBR มีสคริปต์ 2 รายการที่เริ่มต้นและตั้งค่า Thread Border Router ดังนี้

cd ot-br-posix
./script/bootstrap
INFRA_IF_NAME=wlan0 ./script/setup

OTBR ทำงานทั้งบนอินเทอร์เฟซ Thread และอินเทอร์เฟซเครือข่ายโครงสร้างพื้นฐาน (เช่น Wi-Fi/Ethernet) ซึ่งระบุด้วย INFRA_IF_NAME อินเทอร์เฟซ Thread สร้างขึ้นโดย OTBR เองและตั้งชื่อเป็น wpan0 โดยค่าเริ่มต้น และอินเทอร์เฟซโครงสร้างพื้นฐานมีค่าเริ่มต้นเป็น wlan0 หากไม่ได้ระบุ INFRA_IF_NAME อย่างชัดเจน หาก Raspberry Pi เชื่อมต่อด้วยสายอีเทอร์เน็ต ให้ระบุชื่ออินเทอร์เฟซอีเทอร์เน็ต (เช่น eth0)

INFRA_IF_NAME=eth0 ./script/setup

ตอนนี้ระบบได้เปิดใช้บริการ otbr-agent แล้ว และจะเริ่มทำงานเมื่อรีบูต หากต้องการเริ่มบริการทันทีโดยไม่ต้องรีบูต ให้ใช้สคริปต์ server

./script/server

ตรวจสอบว่าotbr-agentเปิดใช้งานอยู่

sudo service otbr-agent status
● otbr-agent.service - Border Router Agent
   Loaded: loaded (/lib/systemd/system/otbr-agent.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-03-01 05:46:26 GMT; 2s ago
 Main PID: 2997 (otbr-agent)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/otbr-agent.service
           └─2997 /usr/sbin/otbr-agent -I wpan0 -B wlan0 spinel+hdlc+uart:///dev/ttyACM0

Mar 01 05:46:26 raspberrypi otbr-agent[2997]: Stop publishing service
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: [adproxy] Stopped
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: PSKc is not initialized
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: Check if PSKc is initialized: OK
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: Initialize OpenThread Border Router Agent: OK
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: Border router agent started.
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: [INFO]-CORE----: Notifier: StateChanged (0x00038200) [NetData PanId NetName ExtPanId]
Mar 01 05:46:26 raspberrypi otbr-agent[2997]: [INFO]-PLAT----: Host netif is down

แก้ไขเส้นทาง URL ของสถานีวิทยุ

เอเจนต์ OTBR ใช้/etc/default/otbr-agentไฟล์การกำหนดค่าสำหรับ พารามิเตอร์การเริ่มต้น ไฟล์นี้มีตัวแปร OTBR_AGENT_OPTS ซึ่ง กำหนดการตั้งค่า เช่น URL ของสถานีวิทยุ เช่น spinel+hdlc+uart:///dev/ttyACM0

ไฟล์การกำหนดค่านี้สร้างขึ้นโดย CMake จากไฟล์ต้นฉบับ otbr-agent.default.in จากนั้นจะส่งไปยังบริการของระบบเป็นพารามิเตอร์การเริ่มต้นบริการ

วิธีเปลี่ยนเส้นทาง URL ของสถานีวิทยุในระบบเป้าหมาย

  1. เปิดไฟล์การกำหนดค่าตัวแทน OTBR ในโปรแกรมแก้ไขข้อความ

    sudoedit /etc/default/otbr-agent
    

  2. ค้นหาตัวแปร OTBR_AGENT_OPTS

  3. ค้นหาส่วน URL ของสถานีวิทยุในสตริง เช่น spinel+hdlc+uart:///dev/ttyACM0

  4. เปลี่ยนสตริงนั้นเป็นเส้นทางใหม่

  5. บันทึกไฟล์และออกจากโปรแกรมแก้ไข

  6. รีสตาร์ทบริการ otbr-agent เพื่อใช้การเปลี่ยนแปลง

    sudo systemctl restart otbr-agent