$30 off During Our Annual Pro Sale. View Details »

MicroPython × BLE × テプラ 〜リバースエンジニアリングを添えて〜 /micropython-ble-tepra

MicroPython × BLE × テプラ 〜リバースエンジニアリングを添えて〜 /micropython-ble-tepra

PyCon JP 2021 オンライン

Takumi Sueda

October 16, 2021
Tweet

More Decks by Takumi Sueda

Other Decks in Technology

Transcript

  1. MicroPython × BLE ×



    PyCon JP
    2021
    @puhitaku

    View Slide

  2. TEPRA
    2

    View Slide

  3. https://twitter.com/ejo
    090
    /status/
    425
    52
    334
    04
    306
    96
    448
    3

    View Slide

  4. https://twitter.com/okayan
    08
    /status/
    7
    972
    55
    664
    46
    460
    10
    89
    4

    View Slide

  5. https://twitter.com/okayan
    08
    /status/
    5
    658
    60
    495
    74
    418
    43
    22
    5

    View Slide

  6. https://www.kingjim.co.jp/products/tepra/sr
    37
    0
    .html
    6

    View Slide

  7. TEPRA Lite LR
    30
    TEPRA Lite LR
    3
    0
    https://www.kingjim.co.jp/sp/lr
    3
    0
    /
    7

    View Slide

  8. TEPRA Lite LR
    30
    https://www.kingjim.co.jp/sp/lr
    3
    0
    /
    8

    View Slide

  9. TEPRA Lite LR
    30
    9

    View Slide

  10. TEPRA Lite LR
    30 

    https://www.kingjim.co.jp/products/tepra/sr
    37
    0
    .html
    10

    View Slide

  11. TEPRA Lite LR
    30





    11

    View Slide

  12. TEPRA Lite LR
    30
    12

    View Slide

  13. 13

    View Slide

  14. Bluetooth Low Energy (BLE)
    https://www.kingjim.co.jp/sp/lr
    3
    0
    /feature/index.html
    14

    View Slide

  15. Switch Science Bluefruit LE Sni
    ff
    er
    15

    View Slide

  16. Wireshark
    16

    View Slide

  17. BLE
    17
    💻

    View Slide

  18. PC Bluetooth


    2


    Bluetooth


    Bluez Linux BT Python


    BLE
    18
    😇

    View Slide

  19. PC


    Bluetooth


    API




    Wi-Fi BLE


    🥰
    BLE (ESP
    3
    2
    )
    19
    ESPr® Developer
    32
    https://www.switch-science.com/catalog/
    3
    21
    0
    /

    View Slide

  20. MicroPython × BLE ×
    20

    View Slide

  21. MicroPython × BLE ×
    Python


    json, time, asyncio (uasyncio), zlib
    batteries included


    CPython (REPL)



    MicroPython machine

    GPIO
    MicroPython
    21

    View Slide

  22. MicroPython × BLE ×
    BLE bluetooth


    bluetooth.BLE IRQ


    API


    gattc_discover_services
    Service discovery
    prop_write_without_response
    Characteristic


    MicroPython BLE
    22

    View Slide

  23. MicroPython × BLE ×
    0x180f Battery Service


    0x2a19 Battery Level Characteristic


    0xfff0 TEPRA Lite Service


    0xfff1 TEPRA Lite Char.

    Notify (RX)


    0xfff2 TEPRA Lite Char.

    Write Without Response (TX)
    ESP
    3 2
    Service Characteristic
    23
    Characteristic


    View Slide

  24. MicroPython × BLE ×
    0xfff2
    24
    0 5

    View Slide

  25. MicroPython × BLE × 25
    f0 5c =


    00 03 00 00 00 00 00 00 = 1


    00 03 00 00 00 00 00 00 = 2

    View Slide

  26. MicroPython × BLE ×
    f0 5c




    26

    View Slide

  27. MicroPython × BLE ×
    1
    27

    View Slide

  28. MicroPython × BLE ×


    28

    View Slide

  29. PC Wi-Fi ESP
    3
    2
    29
    💻

    View Slide

  30. MicroPython × BLE × 30
    0 5
    REST API
    zlib /prints POST

    View Slide

  31. MicroPython × BLE × 31
    0 5
    CLI
    Pillow QR

    View Slide

  32. REST API
    https://github.com/hugokernel/micropython-
    nanoweb


    asyncio Flask API Web API


    nanoweb
    32

    View Slide

  33. MicroPython × BLE ×
    https://github.com/puhitaku/tepra-lite-esp32
    33
    GitHub

    View Slide

  34. MicroPython

    BLE

    
 

    MicroPython
    34

    View Slide

  35. View Slide