Git Product home page Git Product logo

Comments (1)

Heckie75 avatar Heckie75 commented on June 27, 2024

@TerminalMan
Sorry for late response.

At least the documentation is wrong. According the code the byte for length is not included

Lines 1459ff

# add payload and calculate checksum
  set sum 1
  foreach b $bytes { # iterates over bytes which is the payload w/o static prefix 0x0f  and w/o length!
    lappend full_req $b
    set sum [ expr $sum + [ scan $b %d ] ]
  }
  set sum [ expr $sum & 255 ]
  lappend full_req $sum

  # static suffix 0xffff
  lappend full_req 255
  lappend full_req 255

  return  [ gatt_char_write_req $HANDLES(command) $full_req ]

}

Your python code seems to be correct.

I've double checked this example from debug mode:

[FC:69:47:06:CB:C6][LE]> char-write-cmd 002b 0f0c01000b0d0a0e0107e8000022ffff
Notification handle = 0x002e value: 0f 04 01 00 00 02 ff ff

Checksum is 0x22

this python code also calculates checksum of 0x22

ba = bytearray.fromhex('01000b0d0a0e0107e80000')
sum = 1
for b in ba:
  sum += b

print(hex(sum & 0xff))

In terms of the notification the length-byte is included.

from voltcraft-sem-6000.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.