File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed
Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,19 @@ func ParseFormat6(input string) (Measurement, error) {
1616 if err != nil {
1717 return m , err
1818 }
19- if len (data ) < 27 {
19+ if len (data ) < 23 {
2020 return m , errors .New ("data is too short" )
2121 }
2222
23- if data [8 ] != 0xff { // manufacturer specific data
23+ if data [4 ] != 0xff { // manufacturer specific data
2424 return m , errors .New ("data is not manufacturer specific data" )
2525 }
2626
27- if data [9 ] != ruuviCompanyIdentifier [0 ] || data [10 ] != ruuviCompanyIdentifier [1 ] {
27+ if data [5 ] != ruuviCompanyIdentifier [0 ] || data [6 ] != ruuviCompanyIdentifier [1 ] {
2828 return m , errors .New ("data has wrong company identifier" )
2929 }
3030
31- data = data [11 :]
31+ data = data [7 :]
3232
3333 if data [0 ] != 0x06 { // data format
3434 return m , errors .New ("data is not in data format 6" )
Original file line number Diff line number Diff line change @@ -15,16 +15,12 @@ func buildFullAdvertisementFormat6(payload []byte) []byte {
1515 adv [1 ] = 0x01 // AD Type
1616 adv [2 ] = 0x06 // Flags
1717 adv [3 ] = 0x00 // Padding
18- adv [4 ] = 0x00 // Padding
19- adv [5 ] = 0x00 // Padding
20- adv [6 ] = 0x00 // Padding
21- adv [7 ] = 0x00 // Padding
2218 // Manufacturer specific data
23- adv [8 ] = 0xFF // Manufacturer specific data flag
24- adv [9 ] = 0x99 // Company identifier (Ruuvi)
25- adv [10 ] = 0x04 // Company identifier (Ruuvi)
19+ adv [4 ] = 0xFF // Manufacturer specific data flag
20+ adv [5 ] = 0x99 // Company identifier (Ruuvi)
21+ adv [6 ] = 0x04 // Company identifier (Ruuvi)
2622 // Copy payload
27- copy (adv [11 :], payload )
23+ copy (adv [7 :], payload )
2824 return adv
2925}
3026
You can’t perform that action at this time.
0 commit comments