Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOSDC 2019 BLE

coe
September 01, 2019

iOSDC 2019 BLE

iOSDC 2019 BLE and L2CAP

coe

September 01, 2019
Tweet

More Decks by coe

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ w ೔޲ڧʢ5TVZPTIJ)ZVHBʣ w גࣜձࣾ"NB[JB w !DP⒎FFHZVOZV w IUUQTHJUIVCDPNDPF w

    J1IPOF04ʙ w "OESPJE%POVUʙ w 5JUBOJVN.PCJMF w UW04ʙ
  2. -$"1ʹΑΔ૒ํ޲௨৴ J04 "OESPJE -$"1௨৴༻ͷ $IBOOFMΛ༻ҙ͢Δ CBPeripheralManager#publis hL2CAPChannel(withEncrypti on:) BluetoothAdapter#listenUsin gL2capChannel()

    14.ͱ͍͏൪߸͕෷͍ग़ ͞ΕΔ CBPeripheralManagerDelegat e#peripheralManager(_:didPu blishL2CAPChannel:error:) BluetoothServerSocket# getPsm() 1FSJQIFSBMଆͰ෷͍ग़͞Ε͍ͯΔ 14.Λࢦఆ͠ɺ -$"1$IBOOFMͷΦʔϓϯΛߦ͏ CBPeripheral#openL2CAPChannel(_:) BluetoothDevice# createL2capChannel(psm) BluetoothSocket#connect() -$"1$IBOOFM͕Φʔϓ ϯ͞Εͨ͜ͱΛ͓ޓ͍ݕ஌͢Δ CBPeripheralDelegate#peripheral(_:did Open:error:) CBPeripheralManagerDelegate.periphe ralManager(_:didOpen:error:) BluetoothServerSocket#acc ept() ૒ํ޲௨৴ ޙड़ ޙड़
  3. $FOUSBMˠ1FSJQIFSBM $IBSBDUFSJTUJD ໊લ छผ ໾ׂ 1 σʔλॻ͖ࠐΈ Write with response

    ૹ৴͢Δσʔλͦͷ΋ͷ 2 σʔλॻ͖ࠐΈόΠτ਺௨஌ొ࿥ Notify Central͔ΒPeripheralʹॻ ͖ࠐ·ΕͨRaw DataαΠ ζΛ௨஌
  4. 1FSJQIFSBM J1IPOF1MVT 1FSJQIFSBM 1JYFMB $FOUSBM J1IPOF1MVT - 180 $FOUSBM 1JYFMB

    20 - "OESPJE͸ɺJ04ʹൺ΂ɺഒ΄Ͳͷεϐʔυͷ͕ࠩ͋Δ σʔλॻ͖ࠐΈόΠτ਺
  5. 

  6. 

  7. $FOUSBMXSJUFCZUFT 1FSJQIFSBM J1IPOF 1FSJQIFSBM 1JYFMB 1FSJQIFSBM J1IPOF94.BY $FOUSBM J1IPOF -

    180 180 $FOUSBM 1JYFMB 514 - 514 $FOUSBM J1IPOF94.BY 512 512 - ಉҰ04Ͱ͋ͬͯ΋ɺ୺຤ʹΑͬͯૹ৴Ͱ͖ΔόΠτ਺ʹ͕ࠩग़Δ
  8. 1FSJQIFSBMˠ$FOUSBM $IBSBDUFSJTUJD ໊લ छผ ໾ׂ 1 ಡΈऔΓϦΫΤετ Write with response

    σʔλͷಡΈऔΓ։࢝ό ΠτҐஔΛࢦఆ͢Δ 2 ಡΈऔΓϨεϙϯε௨஌ొ࿥ Notify ಡΈऔΓϦΫΤετ͔Βɺ ૹΓ͍ͨσʔλΛ੾Γऔͬ ͯ௨஌͢Δ
  9. σʔλ͕ਖ਼͘͠ૹΕͳ͍ w όΠτΦʔμʔ -JUUMF&OEJBO #JH&OEJBO ʹ໰୊͕͋Γ·͢ w J04ଆ w όΠτΦʔμʔΛ֬ೝ͢Δ

    #ZUF0SEFS6UJMJUJFT  w $'#ZUF0SEFS(FU$VSSFOU  w "OESPJEଆ w #ZUF#V⒎FSͷѻ͍ʹؾΛ͚ͭΔ w #ZUF#V⒎FSͷॳظόΠτΦʔμʔ͸#JHFOEJBOͰ͢ w #ZUF#V⒎FSPSEFS