1. 12 Nov, 2023 1 commit
    • David Lechner's avatar
      pybricks.common.ble: fix data consistency when observing · 462c1a6f
      David Lechner authored
      In the `ble` module, we maintain a copy of observed advertisement data
      that is updated during servicing of PBIO (contiki) events. These events
      can be triggered any time the GC is invoked, e.g. during allocation of
      memory for MicroPython objects.
      
      In pb_module_ble_observe(), we were iterating over the observed data
      and allocating new MicroPython objects for each item which could trigger
      PBIO events to be run resulting in the observed data being modified
      while we are still iterating over it. This could result in a crash, the
      most likely of which is raising an exception for an invalid data type.
      
      We can avoid this by making a copy of the data before iterating over it.
      
      Fixes: https://github.com/pybricks/support/issues/1278
      462c1a6f
  2. 04 Nov, 2023 4 commits
    • David Lechner's avatar
      drv/bluetooth_btstack: finish TODO to wait for setting advertising data · 90872abc
      David Lechner authored
      This finishes up the REVISIT comment in start_broadcasting_task() to
      actually wait for the set advertising data command to complete before
      the task completes.
      
      This fixes issues with calling the task too fast while the commands
      from the previous call are still pending.
      
      The timer was used to work around the issue but is no longer needed.
      
      Fixes: https://github.com/pybricks/support/issues/1151
      90872abc
    • David Lechner's avatar
      drv/bluetooth_btstack: only set AD params once when broadcasting · e025dce2
      David Lechner authored
      When broadcasting, the advertising parameters dont' change, so we only
      need to set them once when we start broadcasting. This is done by
      moving the code inside the if statement along with the enable function.
      e025dce2
    • David Lechner's avatar
      drv/bluetooth_stm32_cc2640: enable connect whitelist when broadcasting · c2bb78d7
      David Lechner authored
      This changes the GAP discoverable parameters to limit connecting to
      devices in a whitelist. Normally, when broadcasting, the hub should
      not be connectable, but due to some quirks of the Bluetooth chip,
      ADV_NONCONN_IND doesn't work under all circumstances and we have to use
      ADV_IND which makes the device connectable. If another device connects
      while broadcasting, it currently causes things to lock up. However,
      we can prevent devices from connecting in the first place by enabling
      the whitelist (which is empty).
      c2bb78d7
    • David Lechner's avatar
      drv/bluetooth_stm32_cc2640: fix broadcast lockup · b301d97d
      David Lechner authored
      This changes the command to update advertising data on the Bluetooth
      chip in the broadcast task to use HCI_LE_setAdvertisingData() instead of
      GAP_updateAdvertisingData().
      
      It appears there is some sort of memory leak or some such on the
      Bluetooth chip that causes it to lock up if we call the vendor-specific
      GAP_updateAdvertisingData() too many times. It appears that we can work
      around this by calling the standard Bluetooth command
      HCI_LE_setAdvertisingData() instead.
      
      GAP_updateAdvertisingData() would result in two events being sent back
      from the Bluetooth chip, a status event and a command complete event.
      With HCI_LE_setAdvertisingData() we only get a command complete event
      back - with the TI vendor-specific opcode as if we had called
      GAP_updateAdvertisingData().
      
      Fixes: https://github.com/pybricks/support/issues/1095
      b301d97d
  3. 29 Oct, 2023 3 commits
    • David Lechner's avatar
      pbio/task: don't run task from cancel function · 4d386be0
      David Lechner authored
      Since efda5d02 ("drv/bluetooth_stm32_bluenrg: strict ordering of BLE
      tasks"), it is no longer safe to call pbio_task_run_once() anywhere but
      in the main contiki process loop of Bluetooth drivers.
      
      This could break canceling some Bluetooth operations (causing them to
      hang), but this will need to be fixed in a different way. A FIXME
      comment with some suggestions is added to remind us to fix this.
      4d386be0
    • David Lechner's avatar
      pybricks.tools: Revert "Run tasks while awaiting them." · da7565e5
      David Lechner authored
      This reverts commit a50ff187.
      
      The Bluetooth drivers have task queues that prevent more than 1 task
      from running concurrently.
      
      The reverted change broke this safety mechanism by pumping tasks from
      MicroPython causing multiple tasks to run at the same time, overwhelming
      the Bluetooth chip.
      da7565e5
    • David Lechner's avatar
      drv/bluetooth_stm32_cc2640: fix spi transfer sizes · 8830f3b2
      David Lechner authored
      We were always reading/writing 3 extra bytes because we weren't taking
      into account the 3 extra bytes already sent for the header.
      
      Also, real_write_xfer_size is unsigned and can be zero, so we should
      not be subtracting from it.
      
      Also, also, add some comments to clarify where the FCS (checksum) byte
      comes into play.
      8830f3b2
  4. 28 Oct, 2023 1 commit
    • Laurens Valk's avatar
      pybricks.hubs.MoveHub: Use standard hub init. · 5e2d65de
      Laurens Valk authored
      The Move Hub cannot have true vector axes, but we can still use this API to initialize the hub using numeric indices.
      
      This ensures we can use the custom orientation not just in tilt, but also in acceleration like we do on other hubs.
      5e2d65de
  5. 27 Oct, 2023 2 commits
  6. 26 Oct, 2023 7 commits
  7. 24 Oct, 2023 4 commits
  8. 23 Oct, 2023 7 commits
  9. 20 Oct, 2023 4 commits
  10. 30 Jul, 2023 1 commit
  11. 13 Jul, 2023 6 commits