Gå til innhold
  • Bli medlem
Støtt hjemmeautomasjon.no!

Bjørn Mork

Medlemmer
  • Innlegg

    242
  • Ble med

  • Besøkte siden sist

  • Dager vunnet

    19

Oppføring-kommentarer skrevet av Bjørn Mork

  1. Eksempel på en sesjon fra en RPi4 (men en hvilken som helst Linux-boks med nyere  blåtann burde funke):

     

    Finn BLE-dingser i nabolaget:

     

    root@idefix:/tmp# hcitool lescan
    LE Scan ...
    F3:BA:84:AA:5A:48 Netti_01452ec784
    F3:BA:84:AA:5A:48 (unknown)
    58:93:D8:8C:7C:72 (unknown)
    58:93:D8:8C:7C:72 (unknown)
    80:6F:B0:A9:EA:0F (unknown)
    80:6F:B0:A9:EA:0F (unknown)
    ^C

     

    Koble deg til en av de interessante.  Her en Airthings Wave Mini:

     

    root@idefix:/tmp# gatttool -I
    [                 ][LE]> connect 80:6F:B0:A9:EA:0F
    Attempting to connect to 80:6F:B0:A9:EA:0F
    Connection successful

     

    Finn ut hvilke variable du kan lese/skrive ("characteristics" i BLE lingo):

     

    [80:6F:B0:A9:EA:0F][LE]> characteristics 
    handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
    handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
    handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
    handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb
    handle: 0x000d, char properties: 0x02, char value handle: 0x000e, uuid: b42e3b98-ade7-11e4-89d3-123b93f75cba
    handle: 0x0011, char properties: 0x2c, char value handle: 0x0012, uuid: b42e3ef4-ade7-11e4-89d3-123b93f75cba
    handle: 0x0015, char properties: 0x10, char value handle: 0x0016, uuid: b42e41c4-ade7-11e4-89d3-123b93f75cba
    handle: 0x001a, char properties: 0x1c, char value handle: 0x001b, uuid: f000ffc1-0451-4000-b000-000000000000
    handle: 0x001e, char properties: 0x1c, char value handle: 0x001f, uuid: f000ffc2-0451-4000-b000-000000000000
    handle: 0x0022, char properties: 0x14, char value handle: 0x0023, uuid: f000ffc5-0451-4000-b000-000000000000
    handle: 0x0027, char properties: 0x02, char value handle: 0x0028, uuid: 00002a23-0000-1000-8000-00805f9b34fb
    handle: 0x0029, char properties: 0x02, char value handle: 0x002a, uuid: 00002a24-0000-1000-8000-00805f9b34fb
    handle: 0x002b, char properties: 0x02, char value handle: 0x002c, uuid: 00002a25-0000-1000-8000-00805f9b34fb
    handle: 0x002d, char properties: 0x02, char value handle: 0x002e, uuid: 00002a26-0000-1000-8000-00805f9b34fb
    handle: 0x002f, char properties: 0x02, char value handle: 0x0030, uuid: 00002a27-0000-1000-8000-00805f9b34fb
    handle: 0x0031, char properties: 0x02, char value handle: 0x0032, uuid: 00002a29-0000-1000-8000-00805f9b34fb

     

    properties forteller hva som er read/write/notify.  0x02 er read.  Blir fort ekstra nysgjerring på UUIDer som ikke startert med 0000.  Listen overnfor to handles for hver characteristic.  Vi er naturlig nok mest interessert i "value". Så f.eks:

     

    [80:6F:B0:A9:EA:0F][LE]> char-read-hnd 0x000e
    Characteristic value/descriptor: 00 00 14 6e 84 c7 57 0f 58 00 00 00 96 57 13 00 ff ff ff ff 

     

    Nå skal du jo jobbe litt for å få meningen ut av det der om ikke Airthings hadde publisert koden for å parse deler av det.  Dette er 6 * le16 og 2 * le32 integer der vi har:


     

    00 00 - ukjent
    14 6e  - temperaturen i centi-Kelvin (0x6e14/100 - 273,15 = 8,65 °C)
    84 c7 - ukjent
    57 0f - relativ luftfuktighet i % * 100 (0x0f57 / 100 = 39 %rH)
    58 00 - VOC i ppm.  (0x0058 = 88 ppm)
    00 00 - ukjent
    96 57 13 00 - ukjent
    ff ff ff ff - ukjent

     

    Ikke helt rett fram...  Men om man tar en del samples sammen med dekodede verdier fra app eller display så er det ofte mulig å gjette ganske mye.  Vet ikke hvor lang tid jeg hadde brukt på å innse at temperaturen var gitt i Kelvin, dog 🙂

     

    Mange av de andre verdiene er bare ren ascii og dermed nokså lett å få noe fornuftig ut av.  Som f.eks.

     

    [80:6F:B0:A9:EA:0F][LE]> char-read-hnd 0x0032
    Characteristic value/descriptor: 41 69 72 74 68 69 6e 67 73 20 41 53 

     

    Altså "Airthings AS".  Når du er ferdig:


     

    [80:6F:B0:A9:EA:0F][LE]> disconnect 
    
    (gatttool:979948): GLib-WARNING **: 16:32:19.458: Invalid file descriptor.
    [80:6F:B0:A9:EA:0F][LE]> exit
    

     

    • Like 4
    • Thanks 1
×
×
  • Opprett ny...

Viktig informasjon

Vi har plassert informasjonskapsler/cookies på din enhet for å gjøre denne siden bedre. Du kan justere dine innstillinger for informasjonskapsler, ellers vil vi anta at dette er ok for deg.