1. 14 Jun, 2016 1 commit
    • Jakub Pawlowski's avatar
      Fix missing GATT Characteristic from last service · 552e6304
      Jakub Pawlowski authored
      GATT Service is contained between start and end handle. If
      characteristic definition is at end handle, and it's value definition is
      after end handle, it will not be properly discovered. That's because we
      use value_handle instead of attribute_handle to identify
      characteristics.
      
      As a workaround, increase service boundary if value is defined after
      it's definition.
      
      Bug: 29253825
      Change-Id: Ib145aea4f5cf38a1fbb977c301136e16f8f900f7
      552e6304
  2. 18 May, 2016 1 commit
  3. 25 Mar, 2016 1 commit
  4. 22 Mar, 2016 2 commits
    • Jakub Pawlowski's avatar
      Use handles to identify GATT attributes (1/4) · 26f8828c
      Jakub Pawlowski authored
      Bug: 27778668
      Change-Id: Id7454450c1ce2164001a1f9ca0b91f18d84e3fd6
      26f8828c
    • Jakub Pawlowski's avatar
      Restructure GATTC · 36b67072
      Jakub Pawlowski authored
      This patch changes how GATTC is structured. Up till now, it
      contained tBTA_GATTC_CACHE and tBTA_GATTC_CACHE_ATTR. Those
      structures were so ugly, someone hide them inside internal
      header, to make sure noone would ever access them from outside
      GATTC. They are now replaced with:
      tBTA_GATTC_SERVICE,
      tBTA_GATTC_CHARACTERISTIC,
      tBTA_GATTC_DESCRIPTOR and
      tBTA_GATTC_INCLUDED_SVC.
      
      Those looks much better, and were made globally avaliable.
      Thanks to way they're build, we no longer need set of access
      methods, which were also very ugly:
      BTA_GATTC_GetFirstChar
      BTA_GATTC_GetNextChar
      BTA_GATTC_GetFirstIncludedService
      etc.
      
      This patch breaks HID, DO NOT SUBMIT without HID refactor.
      
      Bug: 27455533
      Change-Id: Ic42cfff175e0cc1a0d8e1a1216e2b4b756cbf77d
      36b67072
  5. 09 Mar, 2016 5 commits
    • Jakub Pawlowski's avatar
      Remove bta_gattc_id2handle · ac4ee3a4
      Jakub Pawlowski authored
      Now that the instance id is equal to handle, we no longer need this
      mapping function.
      
      Bug: 27455533
      Change-Id: I6760f8fc81460df8520d4ebf1899ed256ce5ad1e
      ac4ee3a4
    • Jakub Pawlowski's avatar
      Use attribute handle instead of id in GATT cache · 29feba05
      Jakub Pawlowski authored
      Currently we generate an id for each GATT attribute. Those ids
      are used to differentiate between attributes that have the same
      UUID. We need to get rid of those ids because it won't work with
      partial GATT database updates due to "service change"
      notifications. Instead, attribute handles, which are unique
      across the whole GATT database will be used.
      
      This is first patch in series to achieve that. It gets rid
      of id generation, and just assigns handle in place of ids inside
      of gatt cache. Upcoming patches will change the GATT cache API
      and eventually get rid of "id" completly.
      
      Bug: 27455533
      Change-Id: I74c10872ecc223329b8ac7fef4085963bf272624
      29feba05
    • Jakub Pawlowski's avatar
      GATT cache storage refactoring · 56658ccb
      Jakub Pawlowski authored
      Currently when storing GATT cache into file, we save it piece
      after piece, max 10 elements at once. This is not necessary,
      we have enough space to just save all at once.
      Also the logic doesn't need to be so complicated - no need
      to state machine for such simple task.
      
      Bug: 27455533
      Change-Id: I82923dbedfb317835e45e13e0ea28151eb524d37
      56658ccb
    • Jakub Pawlowski's avatar
      Remove dead methods and callbacks · 9fa6990b
      Jakub Pawlowski authored
      Bug: 27455533
      Change-Id: Ie5661577320810468dd635022027a1e1a2f70a3e
      9fa6990b
    • Jakub Pawlowski's avatar
      Simplify UUID handling in GATT cache · 390749a4
      Jakub Pawlowski authored
      Bug: 27455533
      Change-Id: I653b563d3b3c233ffe31b0a35d396a66db363459
      390749a4
  6. 18 Feb, 2016 7 commits
    • Pavlin Radoslavov's avatar
      Fix C/C++ compiler generated warnings · 12265e39
      Pavlin Radoslavov authored
       * Remove unused functions: -Wno-unused-function
       * Fix logical operations that are missing parentheses:
         -Wno-logical-not-parentheses, -Wno-parentheses
       * Add missing braces in initializers: -Wno-missing-braces
       * Remove unused variables: -Wno-unused-variable
       * Fix printf()-like formatting issues: -Wno-format
       * Avoid using unitialized variables:
         -Wno-maybe-uninitialized, -Wno-uninitialized
       * Fix a bug inside bta_gattc_get_gatt_db_impl()
         when the processed GATT DB attribute type is unknown.
       * Fix warnings about missing field initializers:
         -Wno-missing-field-initializers
       * Re-implement macro COMPILE_ASSERT(COND) to fix a compilation warning:
         -Wno-non-literal-null-conversion
       * Fix sign mismatch comparison warnings:
         -Wno-sign-compare
       * Fix warnings related to enum conversion:
         -Wno-enum-conversion
       * Fix warnings related to incompatible pointer types:
         -Wno-incompatible-pointer-types
       * Fix warnings related to enum conversion:
         -Wno-enum-con...
      12265e39
    • Jakub Pawlowski's avatar
      Fix discovery status handling · 0e36a4d1
      Jakub Pawlowski authored
      This typo was introduced in commit 48db2d25 3years ago.
      This cause unnecesary purge of cache and rediscovery even though
      discovery was successfull.
      
      Change-Id: I828e148ad489af1e231d33d7807bbe0e46f445c5
      0e36a4d1
    • Jakub Pawlowski's avatar
      Add handle range to BTA_GATTC_GetGattDb · 12339a80
      Jakub Pawlowski authored
      Change-Id: Iaf0280853278a4f28dde5b952b646096cfb12d97
      12339a80
    • Pavlin Radoslavov's avatar
      Removed checks for NULL returns after osi_calloc() / osi_malloc() · 5fe6f0cf
      Pavlin Radoslavov authored
      Removed explicit checks for NULL pointer returns after calls
      to osi_calloc() and osi_malloc(), because those are not needed.
      If the memory allocation fails, osi_calloc() and osi_malloc()
      will trigger an assert.
      
      Bug: 27048759
      Change-Id: I2791eb2f69c08f991f8fcdef10e101a41568cd95
      5fe6f0cf
    • Jakub Pawlowski's avatar
      Fix possible memory leak · 4bdc3535
      Jakub Pawlowski authored
      Fix possible memory leak when allocating reused server cache control
      block.
      
      Change-Id: I3aab727e4f60e55530f49b0b05ccf2c891c72760
      4bdc3535
    • Pavlin Radoslavov's avatar
      Replaced osi_getbuf()/osi_freebuf() with osi_malloc()/osi_free() · abd70abb
      Pavlin Radoslavov authored
      Removed the alternative buffer allocation osi_getbuf() / osi_freebuf()
      and use instead osi_malloc() / osi_free().
      
      Correspondingly, replaced usage of osi_freebuf_and_reset()
      with osi_free_and_reset().
      
      Bug: 24914560
      Change-Id: I7a9599ba7fa900321f087da684428133eb0ddd6b
      abd70abb
    • Jakub Pawlowski's avatar
      Use dynamic memory for keeping GATT cache · 9df3192b
      Jakub Pawlowski authored
      Change-Id: I60674c47246d8fe2094fe78ce31b752fa2acb89e
      9df3192b
  7. 06 Feb, 2016 1 commit
  8. 04 Feb, 2016 2 commits
    • Pavlin Radoslavov's avatar
      Refactor usage of osi_free() and osi_freebuf() · 20524d39
      Pavlin Radoslavov authored
       * Allow to call osi_freebuf(ptr) on NULL pointers. This simplifies
         the code: a notable number of "if (foo != NULL)" checks are removed.
       * Add new function osi_free_and_reset(p_ptr) that frees the buffer,
         and explicitly resets the pointer to NULL.
         This prevents unintended usage of free memory.
       * Add corresponding function osi_freebuf_and_reset(p_ptr)
       * Minor cleanup around usages of osi_free() and osi_freebuf()
      
      Also:
       * Removed unused function btif_gattc_cleanup()
       * Replaced usage of the following functions with osi_freebuf_and_reset()
         - mca_free_buf()
         - utl_freebuf()
         - btif_hl_free_buf()
       * Replaced usage of rc_supported_event_free() with osi_freebuf()
       * Replaced usage of btif_hl_get_buf() with osi_getbuf()
       * Eliminate some of the osi_get_buf_size() calls
      
      Bug: 22948224
      Change-Id: Ife860658b26274da6f228d7353cb0f1531587337
      20524d39
    • Jakub Pawlowski's avatar
      Don't unregister notifications for unmodified services · 5919554f
      Jakub Pawlowski authored
      Change-Id: Ie02dd72a2d4a423ab532ec84a4d588ab83f3e22b
      5919554f
  9. 29 Jan, 2016 5 commits
  10. 28 Jan, 2016 2 commits
    • Nitin Arora's avatar
      Avoid double memory free and crash during LE discovery or disconnect · 12091a32
      Nitin Arora authored
      1. Prevent GATT operations to proceed if queue is not empty
      
      This change returns a FALSE from GATT enqueue operation, in case
      there is already a GATT command enqueued. This simple change will
      a. Prevent incorrect memory freeing of the currently queued command.
      b. Prevent incorrect dequeing of the ongoing command and enqueing
      another command which will never be executed.
      c. Double free of memory causing segmentation fault
      
      2. Prevent performing pending operations when link is down
      
      This change prevents performing the execution of pending operations
      when the link is disconnected. The pending operation in that case
      is bound to fail thus freeing the memory pointed to by the p_q_cmd
      which is cleaned up again by the discovery completion routine and
      thus causing double free.
      
      Bug:24178843
      Change-Id: Ief2756f289a7db73d251ef7e247774dd3f7fc413
      12091a32
    • Subramanian Srinivasan's avatar
      Adds null check before freeing LE services list · b83028d1
      Subramanian Srinivasan authored
      Prevents the crash which happens when device is
      disconnected during service discovery and the
      services list is not yet properly allocated
      memory and populated. This change frees up the
      services list after discovery complete only when
      it is not null.
      
      Change-Id: I0ced14d2ee133a332fa2fd7c456267438813a600
      b83028d1
  11. 04 Dec, 2015 1 commit
    • Jakub Pawlowski's avatar
      Fix race condition during simultaneous SDP · 1b3ac367
      Jakub Pawlowski authored
      Right now sdp_conn_id and p_sdp_db are stored in static global
      bta_gattc_cb between call to bta_gattc_sdp_service_disc and
      bta_gattc_sdp_callback. If multiple instances of SDP discovery
      are running simultaneously, they override this field, and free
      same memory multiple times. This patch fixes that by making sure
      sdp_conn_id and p_sdp_db are unique for each SDP discovery.
      
      Bug: 25801255
      Change-Id: I8ec52229e906e6b8748db7504f77e1f4d7006fbe
      1b3ac367
  12. 19 Oct, 2015 4 commits
    • Pavlin Radoslavov's avatar
      GKI cleanup - moved GKI buffer allocation wrappers to OSI · 258c2538
      Pavlin Radoslavov authored
      * Moved the following GKI buffer allocation functions to OSI:
        - GKI_getbuf() -> osi_getbuf()
        - GKI_freebuf() -> osi_freebuf()
        - GKI_get_buf_size() -> osi_get_buf_size()
      
        For now we need the osi_getbuf() / osi_freebuf() allocation wrapper,
        because we need to be able to call osi_get_buf_size() on the allocated
        buffer.
        In the future those should be replaced with osi_malloc() / osi_free().
        Currently, the osi_malloc() buffer size internal allocation tracker
       does not always track the size, hence we need the osi_getbuf() wrapper.
      
      * Replaced GKI_MAX_BUF_SIZE with BT_DEFAULT_BUFFER_SIZE
      
      * Added new file include/bt_common.h that can be usee to include
        few files that should be included alost everywhere (e.g. bt_target.h"
        NOTE: This file might be removed in the future and we should include
        everywhere the right set of header files.
      
      * Removed some of the GKI-related references
      
      * Removed file include/gki_target.h
      
      Change-Id: Ie87830e731...
      258c2538
    • Pavlin Radoslavov's avatar
      GKI cleanup - Replaced usage of GKI queue with OSI fixed_queue · 1a3844f9
      Pavlin Radoslavov authored
      * Added new functions to OSI:
        - fixed_queue_init()
        - fixed_queue_length()
        - fixed_queue_try_remove_from_queue()
        - fixed_queue_try_peek_last()
      
      * Renamed fixed_queue_try_peek() to fixed_queue_try_peek_first()
      
      * Replaced usage of GKI queue functions with OSI fixed_queue functions:
        - GKI_init_q() -> fixed_queue_new(SIZE_MAX)
          NOTE: unlike GKI_init_q(), fixed_queue_new() allocates memory /
          state that needs to be released by calling fixed_queue_free()
        - GKI_enqueue() -> fixed_queue_enqueue()
        - GKI_dequeue() -> fixed_queue_try_dequeue()
          NOTE: fixed_queue_try_dequeue() is non-blocking
        - GKI_queue_length() -> fixed_queue_length()
        - GKI_queue_is_empty() -> fixed_queue_is_empty()
        - GKI_getfirst() -> fixed_queue_try_peek_first()
        - GKI_getlast() -> fixed_queue_try_peek_last()
        - GKI_remove_from_queue() -> fixed_queue_try_remove_from_queue()
        - Queue elements iteration.
          In the fixed_queue implementation we have to use the underlying
          list_t mechanism to iterate over the elements.
          OLD:
            p = GKI_getfirst(queue);
            ...
            while ((p = GKI_getnext(p) != NULL) {
               ...
            }
          NEW:
            list_t *list = fixed_queue_get_list(queue);
            for (const list_node_t *node = list_begin(list);
                 node != list_end(list); node = list_next(node)) {
                p = list_node(node);
            }
      
      * Remove initialization of the GKI module, because it is not needed
        anymore
      
      * Removed unused files in GKI:
        gki/common/gki_common.h
        gki/ulinux/gki_int.h
        gki/ulinux/gki_ulinux.c
      
      Change-Id: I3ff9464db75252d6faf7476a9ca67c88e535c51c
      1a3844f9
    • Pavlin Radoslavov's avatar
      GKI cleanup - Eliminate usage of pool buffers · 2e3d006b
      Pavlin Radoslavov authored
      * Replace usage of function GKI_getpoolbuf() with GKI_getbuf()
      * Remove usage of function GKI_poolutilization()
      * Remove usage of function GKI_poolfreecount()
      
      Change-Id: Ide938192b878bbfb4912642c903fce548f2b5368
      2e3d006b
    • Pavlin Radoslavov's avatar
      Eliminate recursive calling when handling GATT related errors · 7b4fdb40
      Pavlin Radoslavov authored
      If there are errors when processing GATT related events (e.g.,
      configuring the MTU), don't use recursive calls into
      bta_gattc_sm_execute(), because it breaks the free-ing of some
      of the memory.
      
      Bug: 23756301
      Change-Id: I3c685170e868ffbf4e488d2bb5a31904e3f7b39d
      7b4fdb40
  13. 06 Oct, 2015 1 commit
    • Pavlin Radoslavov's avatar
      GKI cleanup - moved GKI buffer allocation wrappers to OSI · a11035b5
      Pavlin Radoslavov authored
      * Moved the following GKI buffer allocation functions to OSI:
        - GKI_getbuf() -> osi_getbuf()
        - GKI_freebuf() -> osi_freebuf()
        - GKI_get_buf_size() -> osi_get_buf_size()
      
        For now we need the osi_getbuf() / osi_freebuf() allocation wrapper,
        because we need to be able to call osi_get_buf_size() on the allocated
        buffer.
        In the future those should be replaced with osi_malloc() / osi_free().
        Currently, the osi_malloc() buffer size internal allocation tracker
       does not always track the size, hence we need the osi_getbuf() wrapper.
      
      * Replaced GKI_MAX_BUF_SIZE with BT_DEFAULT_BUFFER_SIZE
      
      * Added new file include/bt_common.h that can be usee to include
        few files that should be included alost everywhere (e.g. bt_target.h"
        NOTE: This file might be removed in the future and we should include
        everywhere the right set of header files.
      
      * Removed some of the GKI-related references
      
      * Removed file include/gki_target.h
      
      Change-Id: Ie87830e731...
      a11035b5
  14. 05 Oct, 2015 1 commit
    • Pavlin Radoslavov's avatar
      GKI cleanup - Replaced usage of GKI queue with OSI fixed_queue · bba583cd
      Pavlin Radoslavov authored
      * Added new functions to OSI:
        - fixed_queue_init()
        - fixed_queue_length()
        - fixed_queue_try_remove_from_queue()
        - fixed_queue_try_peek_last()
      
      * Renamed fixed_queue_try_peek() to fixed_queue_try_peek_first()
      
      * Replaced usage of GKI queue functions with OSI fixed_queue functions:
        - GKI_init_q() -> fixed_queue_new(SIZE_MAX)
          NOTE: unlike GKI_init_q(), fixed_queue_new() allocates memory /
          state that needs to be released by calling fixed_queue_free()
        - GKI_enqueue() -> fixed_queue_enqueue()
        - GKI_dequeue() -> fixed_queue_try_dequeue()
          NOTE: fixed_queue_try_dequeue() is non-blocking
        - GKI_queue_length() -> fixed_queue_length()
        - GKI_queue_is_empty() -> fixed_queue_is_empty()
        - GKI_getfirst() -> fixed_queue_try_peek_first()
        - GKI_getlast() -> fixed_queue_try_peek_last()
        - GKI_remove_from_queue() -> fixed_queue_try_remove_from_queue()
        - Queue elements iteration.
          In the fixed_queue implementation we have to use the underlying
          list_t mechanism to iterate over the elements.
          OLD:
            p = GKI_getfirst(queue);
            ...
            while ((p = GKI_getnext(p) != NULL) {
               ...
            }
          NEW:
            list_t *list = fixed_queue_get_list(queue);
            for (const list_node_t *node = list_begin(list);
                 node != list_end(list); node = list_next(node)) {
                p = list_node(node);
            }
      
      * Remove initialization of the GKI module, because it is not needed
        anymore
      
      * Removed unused files in GKI:
        gki/common/gki_common.h
        gki/ulinux/gki_int.h
        gki/ulinux/gki_ulinux.c
      
      Change-Id: I3ff9464db75252d6faf7476a9ca67c88e535c51c
      bba583cd
  15. 22 Sep, 2015 1 commit
    • Pavlin Radoslavov's avatar
      GKI cleanup - Eliminate usage of pool buffers · 24d87399
      Pavlin Radoslavov authored
      * Replace usage of function GKI_getpoolbuf() with GKI_getbuf()
      * Remove usage of function GKI_poolutilization()
      * Remove usage of function GKI_poolfreecount()
      
      Change-Id: Ide938192b878bbfb4912642c903fce548f2b5368
      24d87399
  16. 08 Sep, 2015 1 commit
  17. 06 Aug, 2015 1 commit
    • Marie Janssen's avatar
      build: LOG_TAG consistency, include order, build fixes · 49a86709
      Marie Janssen authored
      Fix the order of includes across a bunch of files, and declare LOG_TAG
      at the top of every file in which it is used.
      
      Consistently use bt_ as a LOG_TAG prefix.
      Fix issues with LOG macro usage.
      Remove unused includes and double-includes (when in related .h)
      
      Add includes as necessary to compile cleanly (problems surfaced by
      reordering includes)
      
      Change-Id: Ic55520c8302b06bbc1942c10c448b20844669da6
      49a86709
  18. 16 Jul, 2015 1 commit
    • Arman Uguray's avatar
      Properly disconnect GATT connection during noisy scans · 50333a25
      Arman Uguray authored
      This patch fixes an issue that is reproducible in highly noisy environments
      (massive deployment of BLE beacons), through repeated connect/disconnect
      attempts on a remote peripheral while scanning for beacons in the background.
      The state machine in bta/gatt has a special control flow for handling disconnect
      requests during discovery, which in this case failed to resolve the original
      request by issuing an HCI_Disconnect command. This is now fixed by always
      explicitly triggering the connection close sequence once the discovery state has
      been cleaned up.
      
      This patch also includes a fix for a crash that occurred as a side-effect of the
      scenario described above.
      
      Bug: 22350508
      Change-Id: Ie9cbd3c8f54239b142bfb8dde80d9581ae70ed43
      50333a25
  19. 08 Jul, 2015 1 commit
  20. 07 Jul, 2015 1 commit