Interface

Bike Clients

Vanmoof S3/X3

class pymoof.clients.sx3.BellTone(value)[source]

An enumeration.

class pymoof.clients.sx3.LockState(value)[source]

An enumeration.

class pymoof.clients.sx3.SX3Client(bleak_client: bleak.backends.client.BaseBleakClient, key: str, user_key_id: int)[source]

A wrapper around a bleak client that allows bluetooth communication with a Vanmoof S3 and X3.

You must provide this object with a connected BleakClient and a hexidecimal string formatted key for the bike.

Parameters
  • bleak_client – Connected bleak.backends.client.BaseBleakClient

  • key – The encryption key for the bike from Vanmoof servers

  • user_key_id – The user key id for the bike from Vanmoof servers

async authenticate() None[source]

Attempts to authenticate with the bike by performing the nonce challenge.

Warning

This method will not check if you have successfully authenticated and will silently return.

async get_battery_level() int[source]

Must be authenticated to call

Gets the battery level of the bike out of 100.

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

Battery level as an integer between 0 and 100 inclusive.

async get_distance_travelled() float[source]

Must be authenticated to call

Gets the distance travelled of the bike in kilometers.

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

A float that represents the distance travelled in kilometers.

async get_frame_number() str[source]

No authentication needed to call

Returns the frame number of the bike.

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

A string that represents the frame number.

async get_light_mode() int[source]

Must be authenticated to call

Gets the light mode. TODO: parse output

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

N/A

async get_lock_state() pymoof.clients.sx3.LockState[source]

Must be authenticated to call

Gets the lock state of the bike.

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

A pymoof.clients.sx3.LockState of the lock state of the bike.

async get_power_level() int[source]

Must be authenticated to call

TODO: Need to figure out what this actually returns

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

N/A

async get_sound_volume() int[source]

Must be authenticated to call

Gets the sound volume. TODO: parse output

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

N/A

async get_speed() int[source]

Must be authenticated to call

Gets the current speed of the bike in kilometers per hour

Raises

bleak.exc.BleakError – if the client is not authenticated.

Returns

An integer that represents the speed of the bike in kilometers per hour.

async play_sound(sound: pymoof.clients.sx3.Sound, count: int = 1)[source]

Must be authenticated to call

Plays a sound some number of times.

Parameters
  • sound – The sound to use. See pymoof.clients.sx3.Sound for a list of valid sounds.

  • count – An integer greater than 1. Defaults to 1.

Raises
  • bleak.exc.BleakError – if the client is not authenticated.

  • AssertionError – if count is outside the valid range.

async set_bell_tone(bell_tone: pymoof.clients.sx3.BellTone) None[source]

Must be authenticated to call

Sets the bell tone for the bike.

Parameters

bell_tone – The type of bell tone to use. See pymoof.clients.sx3.BellTone for a list of valid bell tones.

Raises

bleak.exc.BleakError – if the client is not authenticated.

async set_lock_state(state: pymoof.clients.sx3.LockState) None[source]

Must be authenticated to call

Sets the lock state for the bike.

Parameters

state – The lock state to use. See pymoof.clients.sx3.LockState for a list of lock states.

Raises

bleak.exc.BleakError – if the client is not authenticated.

async set_power_level(level: int) None[source]

Must be authenticated to call

Sets the power level for the bike.

Parameters

level – An integer between 0 and 5 inclusive.

Raises
  • bleak.exc.BleakError – if the client is not authenticated.

  • AssertionError – if level is outside the valid range.

class pymoof.clients.sx3.Sound(value)[source]

An enumeration.

Bike GATT Objects

Vanmoof S3/X3

class pymoof.profiles.sx3.SX3Profile(key: str, user_key_id: int)[source]

Represents the profile for the GATT UUIDs for the S3/X3. Also contains functionality to encrypt and decrypt BLE payloads, as well as building the authentication payload.

Parameters
  • key – The hexidecimal string of the encrypted key from Vanmoof servers.

  • user_key_id – Int of the user key id from Vanmoof servers.

class BikeInfo(value)[source]

An enumeration.

class BikeState(value)[source]

An enumeration.

class Defense(value)[source]

An enumeration.

class Light(value)[source]

An enumeration.

class Movement(value)[source]

An enumeration.

class Security(value)[source]

An enumeration.

class Sound(value)[source]

An enumeration.

build_authentication_payload(nonce: bytes) bytes[source]

Builds the authentication payload given a nonce.

Parameters

nonce – A bytes array that represents the nonce from a challenge response.

build_encrypted_payload(nonce: bytes, data: bytes) bytes[source]

Encrypts data signed with a nonce. This will build a payload and pad with zeroes to the nearest multiple of 16 bytes.

Parameters
  • nonce – A bytes array that represents the nonce from a challenge response.

  • data – A bytes array of data.

decrypt_payload(data: bytes) bytes[source]

Decrypts a bluetooth payload.

Parameters

data – A bytes array of data. Must be a multiple of 16 bytes long.