Commit graph

656 commits

Author SHA1 Message Date
Marti Bolivar 7394401baf Bluetooth: ipsp: use sys_log
Various of the printk messages in this sample app don't have
newlines. Let's fix the output by moving to SYS_LOG_xxx() macros
instead, which don't need them anyway.  This also makes it easier to
tell errors apart from other messages, etc.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-08-15 22:58:02 +03:00
Ricardo Salveti 8dbb388000 samples: Bluetooth: add HCI SPI raw handler sample
Add a sample application that allows a Zephyr-based Bluetooth
controller to interface with an HCI driver via SPI. This sample
implements the same BT SPI protocol already as Zephyr's HCI SPI
driver.

Currently, the sample only supports the legacy SPI API.

Provide a single configuration file, avoiding board-specific
files. Some board-specific configuration information must be provided
via other means:

- CONFIG_BT_CONTROLLER_TO_HOST_SPI_DEV_NAME
- CONFIG_BT_CONTROLLER_TO_HOST_SPI_IRQ_DEV_NAME
- CONFIG_BT_CONTROLLER_TO_HOST_SPI_IRQ_PIN

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-08-15 22:58:02 +03:00
Carles Cufi d5c13a7530 Bluetooth: controller: Rename Kconfig prefix
Rename the BT_CONTROLLER prefix used in all of the Kconfig variables
related to the Bluetooth controller to BT_CTLR.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-14 15:44:56 +03:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Johan Hedberg 51252bdea4 Bluetooth: samples/mesh_demo: Fix tune generation with sharp notes
The parsing of strings with sharp notes (e.g. "100C#") was incorrectly
implemented. Now it should be correct. Additional benefit is that this
should fix Coverity CID 173632.

Jira: ZEP-2467

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-08 13:10:29 +03:00
Johan Hedberg bf8e504588 Bluetooth: Mesh: Fix duplicate const declarations
Remvoe duplicate const declarations which may cause compiler warnings.

Jira: ZEP-2442

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-07 19:18:02 +03:00
Luiz Augusto von Dentz e57b7ec4ba Bluetooth: ipsp: Use CONFIG_NET_APP_BLUETOOTH_NODE
Make use of CONFIG_NET_APP_BLUETOOTH_NODE to enable advertising and
registering the necessary services.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-04 18:18:40 +03:00
Johan Hedberg 0be8414e2f Bluetooth: samples/mesh: Increase GATT TX buffer count
Count of 4 seems to cause deadlocks with some Android phones due to
other GATT activity in addition to Mesh related data.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-03 13:10:30 +03:00
Inaky Perez-Gonzalez 3d498dd10c build: workaround build bug in tests
When an app uses a construct such as:

obj-y = main.o ../../../../samples/bluetooth/gatt/hrs.o

in its makefile, it causes said object module to be built in the
source tree, not in the object tree.

When building massively parallel, this usually resuls on the files
getting corrupted, leading to bugs such as:

https://jira.zephyrproject.org/browse/ZEP-2316
https://jira.zephyrproject.org/browse/ZEP-2317

src/../../../../samples/bluetooth/gatt/.gap.o.cmd:3: warning: NUL character seen; rest of line ignored
src/../../../../samples/bluetooth/gatt/.gap.o.cmd:4: warning: NUL character seen; rest of line ignored
src/../../../../samples/bluetooth/gatt/.gap.o.cmd:5: *** missing separator.  Stop.

as multiple build are trying to touch the same file in the source tree
and of course, race and causes a build bug.

We have known about this issue for a long time, but it requires
modifications in the build system that there is no time to tackle.

A suggested workaround is to include the source files into a local .c
file, so this is what this patch does, to remove the random noise.

Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2017-07-27 14:09:40 -04:00
Johan Hedberg ee3b715d1d Bluetooth: samples/mesh: Update generic nRF51 16k configuration
Update the configuration with the latest fine-tuning that was already
present in microbit.conf.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-27 13:51:34 -04:00
Johan Hedberg 28ce610a06 Bluetooth: samples/mesh: Disable unnecessary debug logs
There's no need for debug logs by default in the mesh sample, and it
just contributes excessively to the ROM footprint.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-27 13:51:34 -04:00
Anas Nashif 977537107e samples: mesh: build sample where they fit
Not easily done using RAM/ROM filters, configurations need to be adapted
to make this fit on more devices. Limit the target platforms now while
we figure out configurations.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-27 07:47:53 -04:00
Anas Nashif 9f642c4291 samples: mesh: build only on BLE platforms
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 07:23:14 -04:00
Paul Sokolovsky 4732452a42 samples: bluetooth: ipsp: Bump max number of contexts
This sample includes builtin UDP and TCP echo servers, max
MAX_CONTEXTS=3 as set previously, they just didn't work.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-22 10:33:29 +03:00
Johan Hedberg 0ec2630882 Bluetooth: Mesh: Add initial implementation
Add an initial implementation for the Bluetooth Mesh Profile
Specification. The main code resides in subsys/bluetooth/host/mesh and
the public API can be found in include/bluetooth/mesh.h. There are a
couple of samples provided as well under samples/bluetooth and
tests/bluetooth.

The implementation covers all layers of the Bluetooth Mesh stack and
most optional features as well. The following is a list of some of
these features and the c-files where the implementation can be found:

 - GATT & Advertising bearers (proxy.c & adv.c)
 - Network Layer (net.c)
 - Lower and Upper Transport Layers (transport.c)
 - Access Layer (access.c)
 - Foundation Models, Server role (health.c & cfg.c)
 - Both PB-ADV and PB-GATT based provisioning (prov.c)
 - Low Power Node support (lpn.c)
 - Relay support (net.c)
 - GATT Proxy (proxy.c)

Notable features that are *not* part of the implementation:

 - Friend support (initial bits are in place in friend.c)
 - Provisioner support (low-value for typical Zephyr devices)
 - GATT Client (low-value for typical Zephyr devices)

Jira: ZEP-2360

Change-Id: Ic773113dbfd84878ff8cee7fe2bb948f0ace19ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-20 09:30:44 +03:00
Luiz Augusto von Dentz ca9c8a2627 Bluetooth: ipsp: Remove requirements section
All supported driver are HCI based so there is no need have it state on
the README.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-07-17 17:45:46 +02:00
Luiz Augusto von Dentz 94409a14ae Bluetooth: ipsp: Disable debug options
This disable debug options in order for the image to fit in boards
such as arduino_101 and quark_se_c1000_devboard.

For convenience this adds another configuration file with as it was
available previously which can be build using:

make CONF_FILE=prj_dbg.conf

JIRA: ZEP-2378
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-07-12 17:37:45 +03:00
Geoff Gustafson 1405627c37 net: context: Use K_NO_WAIT instead of 0 for timeout
Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
2017-07-10 10:59:28 +03:00
Kumar Gala 5920acef8a samples: mark samples that require usb_device support
Add depends_on usb_device for those samples that need it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-07 09:01:01 -05:00
Jukka Rissanen 3604c391e6 net: udp: Remove NET_UDP_HDR() macro and direct access to net_buf
Remove NET_UDP_HDR() macro as we cannot safely access UDP header
via it if the network packet header spans over multiple net_buf
fragments.

Fixed also the UDP unit tests so that they pass correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Carles Cufi c170855825 Bluetooth: hci_uart: Set the UART TX size correctly
Since the controller comes with a transmit buffer size that mirrors the
maximum size of a transmit packet, use that to size the buffers that are
used in the hci_uart application to receive packets from the Host over
the UART.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-07-05 16:59:31 +02:00
Johan Hedberg 30beef9419 Bluetooth: GATT Introduce BT_GATT_CCC_MAX helper define
The worst-case maximum number of CCC entries we need is actually
MAX_CONN + MAX_PAIRED. Provide a helper define for it and use it
whenever appropriate.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-04 17:30:40 +03:00
Vinayak Kariappa Chettimada 6cc00f0ee3 Bluetooth: samples: scan_adv: Select BROADCASTER and OBSERVER
Explicitly select CONFIG_BLUETOOTH_BROADCASTER and
CONFIG_BLUETOOTH_OBSERVER in the scan_adv sample.

If the Controller is included without connections support
then only broadcaster support is compiled in by default,
hence add broadcaster and observer role support explicitly
in the prj.conf file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-06-30 13:42:33 +03:00
Johann Fischer 08df5961b3 arch: intel_quark: use DW device driver when USB is selected
This patch allows more generic USB configuration in the samples
and removes platform dependent driver configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-06-28 15:14:15 -04:00
Anas Nashif 6ff291a174 tests: do not exclude quark_d2000_crb
quark_d2000_crb does not build net/bluetooth tests by default now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-27 17:44:23 -04:00
Anas Nashif 3c50f7aa12 tests: samples: remove duplicate filtering
We have many testcases doing filtering both on the architecture level
and the platform level, which is redundant. Also many testcases are
running the same test twice on the same SoC for no good reason, cleanup
the tests and cleanup the filtering.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-27 17:44:23 -04:00
Anas Nashif 3afb47887f samples: hci_uart: optimize testcase definition
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-22 09:22:48 -04:00
Carles Cufi 634d3b46a9 Bluetooth: Set hci_uart RAM config to fit privacy
With the introduction of privacy, the system workqueue is now being
linked into the image, growing the RAM footprint considerably.

In order for the sample to fit in QFAA and QFAB variants of the nRF51
(16KB of RAM) we reduce the workqueue stack size to 512 since the RPA
update mechanism doesn't use more than 340 bytes and we stick to 16
connections maximum.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-06-22 14:40:23 +03:00
Anas Nashif 470c5f3189 tests: remove testcase.ini files
We now use yaml files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif cc24f4b03c tests: samples: convert testcase files to yaml
This will prepare test cases and samples with metadata and information
that will be consumed by the sanitycheck script which will be changed to
parse YAML files instead of ini.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Luiz Augusto von Dentz 79af35991b Bluetooth: GATT: Add bt_gatt_register_service
This adds bt_gatt_register_service using bt_gatt_service which contains
the attribute array that is then added to the database saving a pointer
in each and every attribute declared.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-06-15 21:53:00 +03:00
Luiz Augusto von Dentz d837a6ec4b Bluetooth: GATT: Add GAP service by default
GAP is mandatory service and now that the db can only be build
dynamically there is no reason to keep the applications registering it.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-06-15 21:53:00 +03:00
Luiz Augusto von Dentz b3cfabab63 Bluetooth: Remove CONFIG_BLUETOOTH_GATT_DYNAMIC_DB
Removes CONFIG_BLUETOOTH_GATT_DYNAMIC_DB in preparation to the
introduction of bt_gatt_unregister.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-06-15 21:53:00 +03:00
David B. Kinder 342bdda760 doc: spelling fixes in samples/ and boards/
regular spelling check on .rst files

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-06-12 18:28:08 -04:00
Andrew Boie e87eacacfa samples: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Sharron LIU 3970cd4a87 samples: fixed typo in README.rst
Per ISSM team feedbacks:
“demostrating” >> “demonstrating”
“demonstates” >> ”demonstrates”

Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-06-07 22:53:54 -04:00
Luiz Augusto von Dentz f8c4a34663 Bluetooth: ipsp: Enable CONFIG_BLUETOOTH_SHELL
This enabled testing CONFIG_BLUETOOTH_SHELL with configuration other
than btshell and enables ipsp sample to use bt shell module which
allows to disconnect, print metrics, etc.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-05-29 10:42:21 +03:00
Johan Hedberg 9516d63836 Bluetooth: Remove support for NBLE
NBLE has been deprecated for a few releases now and can be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-05-25 09:03:16 -07:00
Carles Cufi 6c9e563c92 Bluetooth: Move common code to common/
Since more and more code is going to be reused by both the Host and the
Controller, this commit introduces a common/ folder that will contain
everything that is not tied to one of the two components but shared by
them.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-05-12 12:56:14 +03:00
Andrew Boie 39962dc92c samples: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Johan Hedberg 18593e74e1 Bluetooth: samples: Fix passkey display
Passkeys are always 6 digits in length and should therefore be
zero-padded if necessary.

Jira: ZEP-2113

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-05-05 11:25:57 +03:00
Carles Cufi 689bd232f8 Bluetooth: Reshuffle Kconfig options
In order to achieve proper sharing of configuration options, everything
that is common to both the Host and the Controller should now be placed
in the top-level Kconfig file, and Controller-only options are in the
controller/ Kconfig one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-05-04 11:27:04 +03:00
Carles Cufi 7a0588ac9f samples: bluetooth: Set DT baud rate for nRF5x boards
Since most of nRF5x-based boards can be used either as a standalone
development kit or as a BLE controller to connect to an external host,
add DT overlays so that the baud rate is correctly set to 1Mbit/s
whenever building the hci_uart sample application.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-05-03 08:43:17 -05:00
Kumar Gala e547533435 samples: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08c682bfc0b80dfa88de859e90a011bcd2db2762
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:53:53 -05:00
Jukka Rissanen da6eba463d Bluetooth: ipsp: Fix compile error in sample app
Some incompatible changes were introduced when net and bluetooth
branches were changed at the same time.

Change-Id: Ifa03f85d26a63ade0fcc029377d54850c0e92451
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:20 +03:00
Tomasz Bursztyka e5896906f6 net: Rename all *_BUF() macros to *_HDR()
Most of these macros are not exactly exposing a buffer, but a specific
header pointer (ipv6, ivp4, ethernet and so on), so it relevant to
rename them accordingly.

Change-Id: I66e32f7c3f2bc75994befb28d823e24299a53f5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Kumar Gala 3c454017b4 Merge "Merge bluetooth branch into master" 2017-04-20 16:55:36 +00:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
Luiz Augusto von Dentz 617842edde Bluetooth: ipsp: Add TX pools for TCP
TCP requires buffers to be acked thus it retain a reference, but L2
driver actually consumes the buffer so it needs a context pool to store
to original ones.

Change-Id: Ie9083ab361d3674c33080f9e7e6c7248aaf7abc3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-20 08:58:09 +03:00
Sathish Narasimman 1f5a809178 Bluetooth: HFP HF: Add support for RING indication cb
This patch adds support for incoming RING indication callback to
notify application.

> ACL Data RX: Handle 256 flags 0x02 dlen 16   [hci0] 167174.600312
      Channel: 65 len 12 [PSM 3 mode 0] {chan 1}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0xef poll/final 0
         Length: 8
         FCS: 0x9a
        0d 0a 52 49 4e 47 0d 0a 9a                       ..RING...

Change-Id: I0469590a77d619f2a842df647d84f4d56dbd4883
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2017-04-08 20:11:54 +03:00
David B. Kinder 2bfff175ab doc: add labels to bluetooth sample docs
Docs need a label at the top so we can use :ref:`labelname`
to create a link to that doc from other docs.

Change-Id: Ide66f75ca8fac0d5f65fbfc50dc9d130cf45b392
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-04 19:51:27 +00:00
Tomasz Bursztyka 0f18ce44f9 net: Rename Kconfig.samples and its main option for future changes
s/SAMPLES/APP for name shortening. Applying the change where relevant.

Not only IP addresse will be available as samples settings there but
also IEEE 802.15.4 channel, pan_id, and more for instance.

Change-Id: I05dd24989bd0c804d9588092d67044a3e063bc88
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:26 +02:00
Luiz Augusto von Dentz 4fb0724a55 Bluetooth: ipsp: Fix checking for NULL pointer
This may cause static analyser error such as the following:

  Null-checking "tmp" suggests that it may be null, but it has already
  been dereferenced on all paths leading to the check.
             if (tmp) {

Change-Id: Id04f8d052d8128003d5b91f7a8303940529ef261
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-03-21 17:05:42 -07:00
Jukka Rissanen d32503f57e net: nbuf: Split one global DATA pool to RX and TX DATA pools
If we receive lot of packets, it might happen that we exhaust
all the DATA buffers in the system. This would prevent from
us sending anything to the network.
Change this by splitting the DATA buffer pool into RX and TX
parts. This way RX flooding cannot consume all DATA buffers
that needs to be sent.

Change-Id: I8e8934c6d5fdd47b579ffa6268721b5eb3d64b6d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Johan Hedberg 9cf9a2f1f2 Bluetooth: samples: Add combined observer & broadcaster app
Add a sample application demonstrating doing continuous scanning and
sending out advertising packets periodically.

Change-Id: I0ce88afd73bed4928ba65472051c0f83ff27a632
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-07 12:21:29 +01:00
Maureen Helm 93a6565dc5 Bluetooth: samples: Add hexiwear_k64 and frdm_k64f to tests
The introduction of device tree broke bluetooth sample builds for the
hexiwear_k64 and frdm_k64f boards. Add these boards to the peripheral_hr
test so this doesn't happen again.

Jira: ZEP-1745

Change-Id: I3e61a83db09cbb5834bd510bff851611e43844a8
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-03-07 12:21:29 +01:00
Andrei Emeltchenko e9b41f764b hci_usb: Add project configuration for tinyTile board.
Makes configuration for tinyTile board.

Change-Id: I823e299dad905387de85fd6d74159c7540bc7edd
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-03-07 11:19:11 +00:00
Andrei Emeltchenko 8ea70851db hci_usb: Fix incorrect length log
Fixes following warning:
...
warning: format '%u' expects argument of type 'unsigned int', but
argument 6 has type 'int32_t * {aka int *}' [-Wformat=]
...

Change-Id: I3ac523b7c8daf08b0c8e7b43aad270306fe5d744
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-03-07 11:18:39 +00:00
Anas Nashif 31f01f8ed6 Merge "Merge net branch into master" 2017-02-08 12:03:09 +00:00
Jukka Rissanen bd3908b2a9 net: nbuf: Add timeout to net_buf getters
This commit changes the net_buf getter functions in nbuf.h
by adding a timeout parameter. These function prototypes
are changed to accept a timeout parameter.
	net_nbuf_get_rx()
	net_nbuf_get_tx()
	net_nbuf_get_data()
	net_nbuf_get_reserve_rx()
	net_nbuf_get_reserve_tx()
	net_nbuf_get_reserve_data()
	net_nbuf_copy()
	net_nbuf_copy_all()
	net_nbuf_push()
	net_nbuf_append()
	net_nbuf_write()
	net_nbuf_insert()

Following convinience functions have not been changed
	net_nbuf_append_u8
	net_nbuf_append_be16
	net_nbuf_append_be32
	net_nbuf_insert_u8
	net_nbuf_insert_be16
	net_nbuf_insert_be32
	net_nbuf_write_u8
	net_nbuf_write_be16
	net_nbuf_write_be32
so they call the base function using K_FOREVER. Use the
base function if you want to have a timeout when net_buf
is allocated.

Change-Id: I20bb602ffb73069e5a02668fce60575141586c0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:35 +02:00
Johan Hedberg 46ed7974b3 Bluetooth: samples: Add missing README.rst files
Add missing README.rst files to the last two samples.

Jira: ZEP-1540

Change-Id: I8dfa6489c6c65872594d4416870e2a41e701595d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-07 10:52:08 +02:00
Johan Hedberg 50678b03cb Bluetooth: Reuse HCI command buffers for the command response
Reduce the pressure on the common RX buffer pool by reusing HCI
command buffers also for the Command Status or Command Complete
response to them. This also implies removing the existing Kconfig
variable for the command buffer sizes since the size is also dependent
on maximum Command Complete event sizes. Instead, reuse the RX buffer
size also for HCI Command buffers.

Change-Id: I006b287d64a0c9ca40de741aa9a424a49a927385
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-05 22:39:25 +02:00
Johan Hedberg 743379c21f Bluetooth: Kconfig: Merge headroom reserve variables into a single one
A subsequent patch will start reusing HCI command buffers for
receiving the response, so the distinction of received vs sent data
headroom would just make the code unnecessarily complex. Instead, just
merge these two variable into a single one.

Change-Id: I31d846331939f1a2270df7ed0c75112825e16493
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-05 22:39:25 +02:00
Luiz Augusto von Dentz e89aebc4d5 net: samples: Add CONFIG_NET_L2_BLUETOOTH_ZEP1656
This enables these samples to interoperate with Linux 6LoWPAN over
Bluetooth implementation while that is being fixed, in the long term
we might remove it from the samples once Linux is fixed.

Jira: ZEP-1656

Change-Id: I8ca9fe5a27f43cebc75b6fe5a436a5e8fcee26d5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-02-03 15:59:20 +02:00
Michael Scott ca6a686495 net: correct in*_addr parameter of net_addr_pton()
Currently, the function accepts a struct sockaddr * but the code
immediately type casts this to either in_addr or in6_addr.  This is
incorrect behavior as the first field in a sockaddr is sa_family_t
and not address data.

So without special knowledge, a developer will use a sockaddr structure
as the parameter and then wonder why the address information isn't being
set correctly.

Let's change this parameter to void * which makes this function similar
to inet_pton().

Jira: ZEP-1616

Change-Id: I1fc9368da999d90feb07c03fac55dcc749d4eba6
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:13 +02:00
Johan Hedberg eb07178236 Bluetooth: samples: Use Kconfig DEVICE_NAME variable when possible
Instead of using a hard-coded string, make the sample use the Kconfig
variable for the device name.

Change-Id: Ib09f594e1cba221f9064318572bd90d38bd2733a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-28 08:43:41 +02:00
Johan Hedberg 4153b6ca1f Bluetooth: Kconfig: Make device name variable generic
Change BREDR_NAME to DEVICE_NAME so it can also be used as the LE
device name.

Change-Id: I9ef55d9dff098372d47d9d5754ad7a7163a65bc0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-28 08:43:41 +02:00
Anas Nashif 11e3d97c99 doc: update bluetooth samples with pointers
Change-Id: I37b653d59f2297619fb92112a418cd2c1ff80cd4
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-26 20:02:35 +00:00
Anas Nashif 3b8925099e Bluetooth: Move Bluetooth docs to rst
Change-Id: I36009f5acd4016ec47edb6dac29e81e58b1ba24f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-24 17:58:59 +00:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Lee Jones 65cd08d925 Bluetooth: samples/beacon: Print message at start of sample
This is very handy for debug purposes.  It provides us with a reassurance
that at least something is happening, even if initialisation does not
complete (hangs forever).

Change-Id: I6ac1bfec84f8a6694f82d14fdc5d2a27aa1fc634
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-01-18 12:24:28 +00:00
Luiz Augusto von Dentz d627509185 Bluetooth: IPSP: Reuse buffer fragments instead of copying
The original buffer fragments can be used to send back a reply directly
since Bluetooth doesn't add anything to then.

Change-Id: Ifeac0e6c3abbd527c79912abc5f5b833b0b52171
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-01-17 15:37:03 +02:00
Johan Hedberg 6ddf827d88 Bluetooth: hci_uart: Remove redundant idle & ISR stack size values
The idle stack already defaults to 256. The ISR stack size of 640 was
intended to make the app fit on 16k nRF51 variants and is now the
default, i.e. it doesn't need to be explicitly set anymore.

Change-Id: I8db3c080e1f84c65b27f931fa48c75bd90a2d3cd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-17 08:44:21 +02:00
Anas Nashif 2bc9d69981 build: abstract emulation and replace qemu goal with run
This will replace the current goal of 'make qemu' with 'make run' and
moves Qemu handling into its own file and into the boards instead of
being architecture specific.

We should be able to add new boards that support some other type of
emulation (by adding scripts/Makefile.<emu type>) and allow the board to
define their own options for the use type of emulation.

'make qemu' will still work, however it will be deprecated, starting
with this commit it is recommended to use 'make run'.

Jira: ZEP-359
Change-Id: I1cacd56b4ec09421a58cf5d010e22e9035214df6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-10 20:20:47 +00:00
Anas Nashif f6e039062a kernel: remove dependency on CONFIG_NANO_TIMERS/TIMEOUTS
Remove legacy option and use SYS_CLOCK_EXISTS where appropriate.

Change-Id: I3d524ea2776e638683f0196c0cc342359d5d810f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-08 18:09:52 +00:00
Anas Nashif eaa06ac40a net: do not skip sanitycheck on samples
Change-Id: I781a908ad998211b34d5f05f53fbf3471e6b9f1b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-06 22:08:14 +00:00
Carles Cufi c2a2841212 bluetooth: hci_uart: Allocate 65 bytes for L2CAP packets
With LE Secure Connections the longest packet we require is 65 bytes
long: 64 bytes of Public Key data + 1 byte SMP opcode.
Extend the size of the L2CAP pool blocks so that they can fit such
packets and therefore one can use 70-byte
CONFIG_BLUETOOTH_CONTROLLER_TX_BUFFER_SIZE to achieve LE Secure
Connections pairing without HCI fragmentation.

Change-id: I2f11b4277ec5a24ceba79bccc7d84c64065b6e84
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2017-01-05 11:05:49 +00:00
Sathish Narasimman 55190c90a1 Bluetooth: samples: handsfree application indicator callback
Displays the present value of the indicators in the Handsfree
application.

Change-Id: I666ff2b15e70de8c1a26b902077d79c5c1a9d5fe
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2017-01-05 12:35:21 +05:30
Carles Cufi 4b7cdd499f bluetooth: Tune stack sizes after measuring with hci_uart
The following readings were obtained after running the peripheral and
central_hr apps in qemu combined with the controller (hci_uart) on nRF51
and nRF52:

Main Stack 380
Idle Stack: 68
ISR stack: 532
Controller RX Stack: 388
HCI TX Stack: 516

The numbers set in this change provide a safety margin from the ones
measured empirically.

Change-id: Ice7ad7f081502e0ea1accf856a7937c0bf0783b2
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Luiz Augusto von Dentz aaf6bbf33c Bluetooth: ipsp: Port sample to native stack
This port ipsp sample to use the native stack so it can be used once
again.

Change-Id: I7975b017b0aa5bd81a1701692ec81527e39d4701
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-01-05 08:49:16 +02:00
Carles Cufi aa150d6f56 Bluetooth: hci_uart: Disable HCI ECC commands temporarily
HCI ECC commands are causing freezes in the controller build. Until
further investigation is done disable them to avoid issues when running
the controller standalone.

Change-id: Ifab0fa362348b72e88adaa5250c914770e4a70ba
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Carles Cufi 80f000ab43 Bluetooth: Rename SEND_STACK to TX_STACK_SIZE
For consistency with RX_STACK_SIZE and the rest of stack sizes, rename
to use the normal naming scheme.

Change-id: Ib8d484482466fa8d629e6329e07b927abdd6f598
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-01-05 08:49:16 +02:00
Johan Hedberg 63f71adc5f Bluetooth: Take advantage of new net_buf_add_mem() API
This helps simplify code that was previously combining net_buf_add()
with memcpy().

Change-Id: If44cf9cd651aba5e544e36567869f147468663eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:16 +02:00
Anas Nashif ef2dd99efb samples: fix path to sanitycheck script
Change-Id: Ic8fae0617faa6495a30bee09b5457a080924172c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-24 17:49:53 +00:00
Anas Nashif a9e879e273 logging: move sys_log to subsys/logging
Move logging out of misc/ to its own subsystem. Anything related to
logging and any new logging features or backends could be added here
instead of the generic location in misc/ which is overcrowded with
options that are not related to eachother.

Jira: ZEP-1467
Change-Id: If6a3ea625c3a3562a7a61a0ba5fd7e6ca75518ba
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:39 +00:00
Luiz Augusto von Dentz 9791274303 Bluetooth: samples: Add extern "C" { } block to GATT header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ applications.

Change-Id: I767a04635b38d8ef7a02e8c7da3a5c99b0bc7709
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-16 11:23:33 +02:00
Johan Hedberg 1c9da665c3 Bluetooth: Remove unnecessary runtime kernel object initialization
There are static initializer macros available for most kernel objects
which we should use whenever possible.

Change-Id: I496f4d05d26801eddd21fae53bdd4fcdc3246fe3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-16 10:27:48 +02:00
Anas Nashif fe958df4dd libc: rework libc selection and reduce Kconfigs
Moved all libc Kconfigs to where the code is and remove the default
Kconfig for selecting the minimal libc. Minimal libc is now the default
if nothing else is configured in.

Removed the options for extended libc, this obviously was restricting
features in the minimal libc without a good reason, most of the
functions are available directly when using newlib, so there is no
reason why we need to restrict those in minimal libc.

Jira: ZEP-1440
Change-Id: If0a3adf4314e2ebdf0e139dee3eb4f47ce07aa89
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-15 22:31:28 +00:00
Johan Hedberg 71c7c01819 net: buf: Remove the need for net_buf_pool_init()
In order to keep the initialization process light-weight, remove
net_buf_pool_init() and instead perform the initialization of the pool
and buffers in a "lazy" manner. This means storing more information
in the pool, and removing any 'const' members from net_buf. Since
there are no more const members in net_buf the buffer array can be
declared with __noinit, which further reduces initialization overhead.

Change-Id: Ia126af101c2727c130651b697dcba99d159a1c76
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-15 09:58:02 +02:00
Marcus Shawcroft 954baea90b random: Restructure RANDOM Kconfig
Restructure the RANDOM Kconfig to match the structure used in other
drivers with a single top level menu.  Move the true random number
generators to appear first in the menu, with pseudo generators at the
bottom.  Do not present pseudo generators if a true random generator
is presented.

This change implies that tests, samples and applications that require
the random driver interface must now select CONFIG_RANDOM_GENERATOR.

In order for tests and samples to build (and run) on platforms that
have no random driver it remains necessary to select
the CONFIG_TEST_RANDOM_GENERATOR.

Note that CONFIG_TEST_RANDOM_GENERATOR retains its original purpose of
enabling a random driver that delivers non random numbers for the
purpose of testing only.

Change-Id: I2e28e44b4adf800e64a885aefe36a52da8aa455a
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-13 22:50:18 +00:00
Marcus Shawcroft fe8d044d9a tests: Remove unnecessary CONFIG_TEST_RANDOM_GENERATOR
Remove CONFIG_TEST_RANDOM_GENERATOR from each test and sample where it
is not required.

Change-Id: I949f8e93c2cb1881622a5e48efeb87c43122a170
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-13 22:50:18 +00:00
Johan Hedberg c3e08c8fea net: buf: Redesigned pool & buffer allocation API
Until now it has been necessary to separately define a k_fifo and
an array of buffers when creating net_buf pools. This has been a bit
of an inconvenience as well as blurred the line of what exactly
constitutes the "pool".

This patch removes the NET_BUF_POOL() macro and replaces it with a
NET_BUF_POOL_DEFINE() macro that internally expands into the buffer
array and new net_buf_pool struct with a given name:

	NET_BUF_POOL_DEFINE(pool_name, ...);

Having a dedicated context struct for the pool has the added benefit
that we can start moving there net_buf members that have the same
value for all buffers from the same pool. The first such member that
gets moved is the destroy callback, thus shrinking net_buf by four
bytes. Another potential candidate is the user_data_size, however
right not that's left out since it would just leave 2 bytes of padding
in net_buf (i.e. not influence its size). Another common value is
buf->size, however that one is also used by net_buf_simple and can
therefore not be moved.

This patch also splits getting buffers from a FIFO and allocating a
new buffer from a pool into two separate APIs: net_buf_get and
net_buf_alloc, thus simplifying the APIs and their usage. There is no
separate 'reserve_head' parameter anymore when allocating, rather the
user is expected to call net_buf_reserve() afterwards if something
else than 0 headroom is desired.

Change-Id: Id91b1e5c2be2deb1274dde47f5edebfe29af383a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-13 21:41:53 +00:00
Anas Nashif 70f9244db7 Merge "Merge net branch into master" 2016-12-05 15:56:26 +00:00
Szymon Janc d1187302e0 Bluetooth: Make bt_send stack requirements a Kconfig option
This allows to fine tune TX stacks size depending on selected HCI
driver. If needed it can be used to tune for monitor too or other
logging mechanism used.

Change-Id: Ib501921da0b786e151083760d85ec58fe3c08b60
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-12-03 17:09:38 +00:00
Szymon Janc 151e37b856 Bluetooth: samples/hci_uart: Use proper stack declaration
Use BT_STACK_NOINIT for tx stack declaration. This makes sure stack
it properly alligned and account for k_thread overhead.

Change-Id: I704958fcc3ce02aba913f6eaee13ae50d2a81591
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-12-03 17:09:38 +00:00
Carles Cufi b1d02621fc Bluetooth: hci_uart: Fix init order in hci_uart bootup
bt_enable_raw() needs to be called before spawning the tx thread,
otherwise there might be an HCI command processed from the UART
before the HCI driver has been opened and therefore initialized.

Change-Id: I050158bd48bebaf8fa2cf6b11efb54b531f70079
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-03 17:09:38 +00:00
Vinayak Chettimada 73a2100bd8 Bluetooth: hci_uart: reduce configured stack sizes
From stack_analyze function, used isr stack is 368 bytes
with the controller build, main stack is 288 bytes and idle
stack is 56 bytes. Hence, configuring sizes of 512, 512,
and 256 bytes for isr, main and idle stacks respectively.

Increased max connections from 16 to 20 utilizing the RAM
free from the reduced stack sizes.

Change-id: I67d073fd1893cafc53d36e89035a6fd931488a46
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-12-03 17:09:38 +00:00