Commit graph

18591 commits

Author SHA1 Message Date
Allan Stephens
99001f8518 Eliminate duplicate declarations of private microkernel timeout APIs
These 3 declarations no longer appear twice in the same include file.

Change-Id: Ia77b84c29741978bea2d74b44d66e9929d2769c4
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
c82e6e8ae3 Cosmetic changes to sys_kernel output
Eliminates confusing references to "channel", and improves
readability of project output.

Change-Id: Ib4f699caae5a015832207a408bd168903e791756
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
b2834dd29f Cosmetic changes to app_kernel output
Eliminates reference to obsolete "channel" terminology.

Change-Id: Icfae1e0ae7ca1b2b723baa5c79848251cb25995c
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
86e4595da5 Cosmetic changes to private microkernel APIs
- Removes unnecessary comment about API being private.
- Removes misleading comment about processor-specific APIs.
- Makes purpose of "service codes" clearer.

Change-Id: I4715609f328b9fa7f334a1b4c3c21441111f228d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
f9b2c757db Rename K_ticker() to _k_ticker()
This API now uses an approved Zephyr OS prefix.

Change-Id: Ia16829d908da9bfaa82f82da47b583a0004cae7d
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
a5f2ccf286 Remove microkernel's tick handler from public API
This API is now a private microkernel API.

Change-Id: I5b26aa927d42923f2076d06f9bdfef371572543e
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
893726ccb6 Eliminate duplicate registration of system tick event handler
Since the system generator pre-registers K_ticker as the handler
for the system tick event, there is no need for the timer driver
to re-register it at run time.

Change-Id: I7f20c19e5c6ccc7dfb6117aa2d2647b9dec0e549
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
063a4d160f Eliminate samples/libc directory
The new build system no longer uses this directory, since it rebuilds
the (minimal) standard C library every time a project is built.

Change-Id: I1ca6b949bfa260f1d262276be653ddd6bd1cc53b
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Allan Stephens
c718f32a49 Eliminate remainder of sanity check support for obsolete -T option
There is no longer any need to retain any support for this option
as a "do nothing" for backwards compatibility reasons.

Change-Id: I4b8fa727f80effdcc3fd92007fc9c50654291175
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:19 -05:00
Dirk Brandewie
5423ba4dfb init.h: Add the ability to set driver_data at build time
Allow the delevoper to specify the address of the driver instance data
object at build time.

Change-Id: I6b311cfc4d38b3425f6283d87d2da65aceb42faa
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:14:19 -05:00
Szymon Janc
b47d14a273 Bluetooth: Fix NULL pointer dereference in flush_cb
conn was never set in struct flush_data passed to flush_cb.

Change-Id: I2a16479bf7660a96f705d1194245da02ee6eeff5
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:19 -05:00
Andrei Emeltchenko
b85f2e8264 Bluetooth: Improve beacon sample documentation
The source is included to the manual and putting more comments helps
to understand the code.

Change-Id: Iefd6db2abf6070fd8c3fabdaf4946bdd7a045544
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Andrei Emeltchenko
fab2d401a1 Bluetooth: Document bt_init and bt_start_advertising
Functions bt_init and bt_start_advertising are referenced in the
doxygen documentation. Documenting them gives better overview.

Change-Id: I70cb19a0a3232ce5abfb22c3a352bf3868c6f8fb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Andrei Emeltchenko
4d73a264bc Bluetooth: Fixing beacon sample build
Fixes compile errors:
...
Makefile:36: /make/env/defs.base: No such file or directory
Makefile:47: /target/make.ukernel: No such file or directory
make: *** No rule to make target '/target/make.ukernel'.  Stop.
...

Change-Id: I693a939510b732ac810d5af756422c58e3f0c3ab
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Andrei Emeltchenko
f627b881d4 Bluetooth: Update README in samples
Fix typo and reformat test to make it more logic and reflecting
doxygen documentation.

Change-Id: Id869f0131132c9287eab71d11ae40d194a20ca20
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
5be2139435 Bluetooth: Add long attribute to peripheral sample
This is useful for testing prepare and execute writes as well as read
blob:

> ACL Data TX: Handle 42 flags 0x00 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0021
< ACL Data RX: Handle 42 flags 0x01 dlen 15
      ATT: Read Response (0x0b) len 64
        Value: 56656e646f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
< ACL Data TX: Handle 42 flags 0x00 dlen 9
      ATT: Read Blob Request (0x0c) len 4
        Handle: 0x0021
        Offset: 0x0040
> ACL Data RX: Handle 42 flags 0x02 dlen 15
      ATT: Read Blob Response (0x0d) len 10
        00 00 00 00 00 00 00 00 00 00                    ..........

Change-Id: If3da3097e3498e79e644b5721aaf63708fe6ab72
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
7250393678 Bluetooth: Add macro for CEP and long descriptors
Add BT_GATT_CEP and BT_GATT_LONG_DESCRIPTOR so which can be used by
a task to declare long attributes.

Change-Id: I37a0bb1851b60f3cdfa7e2f00ade70d5c344abbf
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
66d6cf77ce Bluetooth: Fix GATT CEP not using 16 bits
Characteristic Extended Properties has 16 bits not 8 bits as value.

Change-Id: I307fd27a6d589d6614829df178ff890301a9b6be
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
14ff92cea0 Bluetooth: Handle ATT execute write request
This introduce a new callback called flush to bt_gatt_attr to indicate
when and attribute can cache data, the data is automatically flushed if
regular write request happens and in case of prepare write it checks if
flush is supported otherwise return an error, then upon receiving an
execute write it perform flush over the entire database and respond
with result:

< ACL Data TX: Handle 42 flags 0x00 dlen 6
      ATT: Execute Write Request (0x18) len 1
        Flags: Immediately write all pending values (0x01)
> ACL Data RX: Handle 42 flags 0x02 dlen 5
      ATT: Execute Write Response (0x19) len 0

Change-Id: I2c47f962858b8a741bf40509a648fe2cd6755691
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
186b133028 Bluetooth: Handle ATT prepare write command
Call attribute write callback taking into account the offset and
generate proper responses:

> ACL Data TX: Handle 42 flags 0x00 dlen 69
      ATT: Prepare Write Request (0x16) len 64
        Handle: 0x0021
        Offset: 0x0000
          Data: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
< ACL Data RX: Handle 42 flags 0x01 dlen 15
      ATT: Prepare Write Response (0x17) len 64
        Handle: 0x0021
        Offset: 0x0000
          Data: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> ACL Data TX: Handle 42 flags 0x00 dlen 23
      ATT: Prepare Write Request (0x16) len 18
        Handle: 0x0021
        Offset: 0x003c
          Data: 0000000000000000000000000000
< ACL Data RX: Handle 42 flags 0x02 dlen 23
      ATT: Prepare Write Response (0x17) len 18
        Handle: 0x0021
        Offset: 0x003c
          Data: 0000000000000000000000000000

Change-Id: I4e5d8e8c92fdbf624d1588345878f0b678472401
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
537e65b05b Bluetooth: Update documentation of GATT API
This makes use of new guidelines to document the GATT API.

Change-Id: I5544f449e11dd72c68b0efb15bd06db44ec30279
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Arkadiusz Lichwa
df4257f174 Bluetooth: Track role for connections
When a connection is made, track its role.

Only peripherial/slave role may trigger update of L2CAP connection
parameters.

Change-Id: I72244581650248c7b020c9e5673b73ce46e7399d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
875d519948 Bluetooth: Handle ATT signed write command
Call attribute write callback taking into account the signature length
so only the actual data is used.

Note: It still don't support validating the signature because that depend
on storing CRSK key.

Change-Id: I93973e2997f57e5715080ef56ad85e0eaf11d0fe
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Szymon Janc
985b411455 Bluetooth: Add tester application
This application is intended for automated testing. It used binary
protocol for communication over UART and can be used for driving
Bluetooth stack by external tester.

Currently only single command registering (init) GAP service is
implemented.

Change-Id: I62e151baa2badc0f1297e65591b5f494ff7b841e
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:19 -05:00
Andrei Emeltchenko
49390c988d Bluetooth: Update samples README
Change-Id: I90330676e9724526bc30a34e62635f912277602d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Luiz Augusto von Dentz
679dd4c1a9 Bluetooth: Convert ATT parser to use opcode table
This reduces the amount of code necessary to check minimum size and
to generate error responses.

Note that not every response can be generate using this method since in
some cases the handle must be set to indicate what attribute has failed.

Change-Id: I0dde7461d97e451407935d5ec3cbfedf6542d5e6
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:19 -05:00
Johan Hedberg
08ff927e1a Bluetooth: Fix vxmicro.h include
vxmicro.h has been renamed to zephyr.h

Change-Id: Id9dddeb1803b5148d052758b684111260fe6b9df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Luiz Augusto von Dentz
aa1260999e Bluetooth: Fix persisting CCC config for non-bonded devices
The spec says that CCC shall only be persistent accross connection for
bonded devices:

  'The Client Characteristic Configuration descriptor value shall be
  persistent across connections for bonded devices. The Client Characteristic
  Configuration descriptor value shall be set to the default value at each
  connection with non-bonded devices'.

To handle this now each configuration has a valid field indicating if the
configuration is valid.

Change-Id: Id74ac54f5e23a7a0b286f90dbc9af4e9ee966dd4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:18 -05:00
Szymon Janc
5c6baa942c Bluetooth: Fix peripheral sample build for ARM
LD      microkernel.elf
samples/bluetooth/peripheral/src/built-in.o: In function
    `mainloop':
samples/bluetooth/peripheral/src/main.c:514: undefined reference
     to `sys_rand32_get'
collect2: error: ld returned 1 exit status

Change-Id: Idec91d59fd98ec06f5e5728238cf9d9f6c37eb87
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:18 -05:00
Szymon Janc
ada9a6f66f Bluetooth: SMP: Fix compilation with debugs enabled
This fix following compilation error if CONFIG_BLUETOOTH_DEBUG_SMP
is defined:

In file included from net/bluetooth/smp.c:44:0:
net/bluetooth/smp.c: In function 'bt_smp_irk_matches':
net/bluetooth/smp.c:681:31: error: 'val' undeclared
    (first use in this function)
  BT_DBG("IRK %s bdaddr %s", h(val, 16), bt_addr_str(addr));

Change-Id: I3350620f1f7dc929b949b4483178df66dde55198
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
279f870bff Bluetooth: Add battery level simulation
Add battery level simulation decrementing from 100% by one every
second.

Change-Id: Ic6b819c32b42d65a044223f22e301835510823a4
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Luiz Augusto von Dentz
5963f573b0 Bluetooth: Fix not printing new line in BT_DBG
This was causing output such as bellow:

bt: bt_gatt_attr_write_ccc: No space to store CCC cfgbt: bt_gatt_attr_write_ccc: No space to store CCC cfgDisconnected

Change-Id: I8aff67b9c4b407e8a2da939c27bea05a597dcf67
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
3dca06e700 Bluetooth: trivial: Make struct static
Change-Id: Ife8cc60bca8f5c00c5f47d3996c873a9c031feba
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
960147d829 Bluetooth: Add Manufacturer Name String to DIS
Manufacturer Name String in DIS is a mandatory feature for Heart Rate
profile as specified by HEART RATE PROFILE Spec.

Change-Id: I552b51b68012edfc4389604e91dd43b8b54fe65f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
2be30696a9 Bluetooth: Simulate Heart Rate Measurements
Add Heart Rate simulation using 1 second sleeping loop and this is how
it is recommended in the Heart Rate Service Spec.

Change-Id: I1023a4089bc661a399acf865f4fc7afaf72b8f0f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Mariusz Skamra
a44e4544bd Bluetooth: Use connection callbacks in peripheral sample app
This registers two simple callbacks for connection and
disconnection events.

Change-Id: I9e1f87d9e1a3c8ef457e15a1c30396fba7f7df4a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:18 -05:00
Mariusz Skamra
7f1bff8b2d Bluetooth: Add callbacks for connections
This patch adds callbacks to notify app about connection and disconnection.

Change-Id: If8091254d929fe53d12b153e6f216223a8913f2d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:18 -05:00
Luiz Augusto von Dentz
4baa3b9700 Bluetooth: Fix missing braces
Change-Id: I3ad884e38428c48ee08c3778219508bd21bfa106
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:18 -05:00
Luiz Augusto von Dentz
0000a2d790 Bluetooth: Add check fo connection encrypt flag in ATT
This checks if connection encrypt flag is set if attribute requires
encryption and in case the connection is already encrypted return
success.

Change-Id: I8af4e9786b63a21f478b3aa9f6df448d7f5760c5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:18 -05:00
Luiz Augusto von Dentz
8f6edeebb8 Bluetooth: Handle attribute read/write errors
Respond with an error if attribute read/write return an error.

Change-Id: I9c2f98ac4b73bca5d3714339a47290ca9ae2391b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
aeb448ebba Bluetooth: Add Current Time Notification
Implement Current Time Notification triggered by write().

...
> ACL Data RX: Handle 74 flags 0x02 dlen 17                [hci0]
161704.397398
      ATT: Write Request (0x12) len 12
        Handle: 0x0014
          Data: df07071e0c2e01010000
< HCI Command: Host Number of Comp.. (0x03|0x0035) plen 5  [hci0]
161704.398861
        Num handles: 1
        Handle: 74
        Count: 1
< ACL Data TX: Handle 74 flags 0x00 dlen 5                 [hci0]
161704.398900
      ATT: Write Response (0x13) len 0
> HCI Event: Number of Completed Packets (0x13) plen 5     [hci0]
161704.533356
        Num handles: 1
        Handle: 74
        Count: 1
< ACL Data TX: Handle 74 flags 0x00 dlen 17                [hci0]
161705.189198
      ATT: Handle Value Notification (0x1b) len 12
        Handle: 0x0014
          Data: df07071e0c2e01010000
> HCI Event: Number of Completed Packets (0x13) plen 5     [hci0]
161705.275353
        Num handles: 1
        Handle: 74
        Count: 1
...

Change-Id: I504c4197a0a1d434f7704b76c8abd120eba51b7a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
e3fd3090ba Bluetooth: Rename cmd_rx_queue/fiber to rx_prio_queue/fiber
With the introduction of the Number of Completed Packets event
handling this FIFO & fiber aren't anymore strictly HCI command
completion related. Rename them therefore to something that more
appropriately describes their purpose.

Change-Id: Ia53dea8b5ec0098459f23918a5483075757d9202
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
5efe82a8e9 Bluetooth: Add Number of Completed Packets event to special queue
The Number of Completed Packets HCI event belongs to the same category
as the Command Complete/Status events in that it is likely to unlock a
waiter in one of the other fibers. Events which may affect waiters in
this way need to be processed without delay and through a separate
FIFO & fiber to avoid deadlocks.

Change-Id: Ibc2ee2b4f72e2534a8579ad1c36591867e19e6df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
4c2a6a6b14 Bluetooth: Remove quark target from regression test
After quark UART configuration was refactored it is not working
anymore. Since quark was never an officially supported target just
remove it from the regression tests.

Change-Id: If4bae99f5e0dfecfd3729ac0c42d7fd3d8affa0c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
451b105978 Bluetooth: Use __packed instead of the deprecated PACK_STRUCT
The PACK_STRUCT macro will be removed soon and __packed is what all
code should use. Convert all the usages in Bluetooth code.

Change-Id: Id5c724566565f67fa8167b61398c508194ece89b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
92e3a44b3d Bluetooth: Increase buffer count from 20 to 22
We need to make sure we have more event buffers than outgoing ACL
buffers. Currently we allocate 7 + 7 ACL in/out buffers leaving only 7
left for commands/events. Increase the buffer count by two to make
sure we've got 8 command/event buffers.

Change-Id: I4c54aa07019ad9ef262aeecabf151edd60f91b9e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
1004e8bf19 Bluetooth: Reorganize buffer variable for smaller size
Reorganize and compress some of the buffer variable to achieve smaller
struct size.

Change-Id: I1ce711c22844470403b085b0f13e77f762f25262
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Andrei Emeltchenko
a79c26d9aa Bluetooth: Implement Current Time write
Implement Current Time write callback.

Change-Id: I2a6cb0b411c47e4d20ff34eadf8725bf23b0b7b9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg
5e16f9b849 Bluetooth: Add missing include to gatt.h needed by ARRAY_SIZE
All public headers should be self-contained. Since gatt.h uses the
ARRAY_SIZE macro it should also include the <misc/util.h> header file
that provides it.

Change-Id: I1fea66d10f452e51d9af5f5c6c345b5bb5a92d00
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:18 -05:00
Arkadiusz Lichwa
0225b6b299 Bluetooth: Update simple LE scan app
Adjust app to build system.

Change-Id: I5366ea9b38b261762724006fef0ec61ed3c6e251
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:18 -05:00