Commit Graph

262 Commits

Author SHA1 Message Date
Anas Nashif 1971988397 kconfig: add menu for networking
Move bluetooth and IP stack under the Networking menu.

Change-Id: I820191526d274143e196a7ecaf1ed9b020e8d0ef
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:26 -05:00
Mariusz Skamra 3831217a98 Bluetooth: Fix scan_type in le_set_scan_params
scan_type should be set to BT_LE_SCAN_ACTIVE

Change-Id: I4cb4141919819ce104b002bfc0e89bedbc55e90d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:24 -05:00
Johan Hedberg fa1bf41477 Bluetooth: Fix minor coding style issues
Change-Id: I0e78bce8cdbf46252f4cfc4483995ba7583915f7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Johan Hedberg 4905835bad Bluetooth: Fix max_latency calculation comment
Change-Id: I4afcd6e206b95fe219c3483d1e273d78c1dfcb2f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa ac98b4e221 Bluetooth: Handle update connection parameters
When connected, the peripheral/slave can trigger changing connection parameters.
Handle such request on central/master and if needed update controller settings
regarding the relevant connection parameters.

Change-Id: If3c1d91752f8d3875918bd8bfe923330790f530e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:24 -05:00
Szymon Janc 441e01ec04 Bluetooth: Add bt_conn_get_dst function
This function allows to pick connection destination address.

Change-Id: I3e4959eec00905c64de3d8b9ef810b613c2e9f91
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 0344c11ad7 net: Add preliminary UDP support
Use the Contiki simple UDP API when sending and receiving the
application data.

Change-Id: I39a379f30c8f7febbea223fcf8f8702faf82e39e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen e024dba08f net: uip: Add support for user data in simple UDP API
Adding the user pointer to the uIP simple-udp API is vital so that
we can pass the net_buf to UDP receiver callback.

Change-Id: If7ee24f344fbd23eb7e0c3a99e78deb996d3667d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 7e0951982a net: Add helper function to context for getting recv queue
Needed only in net_init.c so did not put the prototype into .h file.

Change-Id: If84e835d32bcfafd8e403ffa4def51fa72e0aa3e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen e494de2449 net: Simple UDP process declaration was missing
Needed so that UDP process can be called from net init.

Change-Id: Iaa165d7773b7f5851d0088aa0d7480b23e1a9199
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 7d7d4e4161 net: Enable logging in uIP stack
Allow the uIP stack to print information about its internal
status. By default the logging is disabled.

Change-Id: I55a03051d3f541b5f6ea950fdd6406814f937197
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen cc4b282e46 net: Make sure to get the debug prints from uIP to console
Change-Id: Ic4d57f00f4752084ab5bd2ebc9f3f18c4747f1ab
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 6b3c739d7d net: Add helper function to set the link local address
Network driver should call this when it knows the device MAC or
EUI-64 address.

Change-Id: Ie03a80fcdb9a10cd1cb15f12037b3802da13bca9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 0028a541f6 net: uip: Set the link local IPv6 address according to linkaddr
Create a separate utility function to set the IPv6 link local
address using the supplied MAC/EUI-64 address. This is needed
because the net_init() is normally called before the
MAC address is set.

Change-Id: I5d46bd8d802e95a99b4b340d1f37af893b798db8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Jukka Rissanen 8dcb1494a9 net: Fix the environment variable in Makefile
TIMO_ENV changed to ZEPHYR_ENV as that one is now in use.

Change-Id: Ia7d7729a7210401ea2191710c708985c0282257a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa 1d748ba760 Bluetooth: Address conversion user helpers
Adds user helper functions dealing with formatting bluetooth
address.
Refactors internal helpers using public ones.

Change-Id: If7b9f9a93b2aef3d25df55d6cfae9de05d8830b0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa d81689e915 Bluetooth: Introduce LE scan callback
Enables sending LE discovery results to user app.
Updates central apps to use new scan API.

Change-Id: Id319c96e15554f2eed4cf507cddd114ca74aa8e5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:24 -05:00
Luiz Augusto von Dentz afc6628c26 Bluetooth: Use hexadecimal format when printing GATT handles
hexadecimal is the usual format when defining GATT handles values so
printing in the same format makes it easier to debug.

Change-Id: I6babcadaf5a4cffbac73db29c155343540cee120
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Luiz Augusto von Dentz 168446d058 Bluetooth: Disable GATT notifications while disconnected
Once disconnected disable CCC configuration and enabling it back once
reconnected:

bt: bt_gatt_disconnected (0x0010c610): conn 0x0010a1f4
bt: disconnected_cb (0x0010c610): ccc 0x00108e44 reseted
Disconnected
Connected
bt: bt_gatt_connected (0x0010c610): conn 0x0010a1f4
bt: gatt_ccc_changed (0x0010c610): ccc 0x00108e44 value 0x0001

Change-Id: Ia4ac6793176f80ea9c6f255a4d151f9080660b0d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg ea15db12ba Bluetooth: Make bt_conn_lookup_addr_le public
This API is useful for applications wanting to monitor and disconnect
connections.

Change-Id: Ib1a98ece364f137262515fbb1163c6b08ddf792c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 029046e02e Bluetooth: Make connection lookup functions return a new ref
To be able to make these APIs usable for apps where the calls may
happen from preemptible tasks, it's safest to return a dedicated
reference and let the caller do bt_conn_put() once its done with the
object.

Change-Id: If227e088385b8c6f61f4061a54c745c0bff7a6c3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 89e775c1f6 Bluetooth: Fix coding style (missing braces)
Change-Id: I66dcc96da7b00181ff08773642b54ae19b3bdf5f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 8c26ce63d1 Bluetooth: Remove bt_hci_reset() API
There's no clear need for this API (at least for now) and supporting
it means we really need to get all state cleanup procedures correct.
Remove it for now.

Change-Id: Ia2c7d51d410117bef12bc08f4f97a4e38ccfb77a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 9bea2c3cfc Bluetooth: Move HCI driver API to dedicated header file
This makes it clearer that this is a specialized API not intended for
general app usage (unlike most other things in bluetooth.h).

Change-Id: I0ce1d5903610a9b3a99cf0be9f0e1462b04bf45a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 939544b75d Bluetooth: Move logging helpers to a dedicated header file
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.

Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Szymon Janc 19fe40764c Bluetooth: Make bt_stop_scanning parameters explicit void
Change-Id: I47ece76e00719d2fef702763c061055a1e9c5f76
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:23 -05:00
Luiz Augusto von Dentz 801c09757e Bluetooth: Add support for ATT Read Multiple
This adds parsing for ATT Read Multiple Request and Response:

> ACL Data RX: Handle 3585 flags 0x02 dlen 11
      ATT: Read Multiple Request (0x0e) len 6
        Handle: 0x0001
        Handle: 0x0002
        Handle: 0x0003
< ACL Data TX: Handle 3585 flags 0x00 dlen 27
      ATT: Read Multiple Response (0x0f) len 22
        00 18 02 03 00 00 2a 54 65 73 74 20 70 65 72 69  ......*Test peri
        70 68 65 72 61 6c                                pheral

Change-Id: I08efe2b73342423634c156f95baa2bba84bd50a9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:14:23 -05:00
Mariusz Skamra b2574b645b Bluetooth: Terminate connection
Adds routine for termination of connection.

Change-Id: I444e4cba3297c51fbd9f89bbdba89db45af195c6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:23 -05:00
Arkadiusz Lichwa f5ae4b70f1 Bluetooth: Add basic interface for LE connection
Adds internal HCI interface routine for creation of basic ACL LE link.
Most of the command interface parameters are fixed.
The internal interface is then used directly by simple public interface with
no connection validation.

Change-Id: I8ed72a9d01348e2a05b62facc9e85060e4500631
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 224abaab0e Bluetooth: Update bt_conn_cb to pass bt_conn instead of bt_addr_le_t
Now that we have a publicly exposed connection object it makes sense
to pass that to the connection callbacks rather than an address.

Change-Id: I8e9b17733d1789539a83c3dbc7a778336d2b71ff
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 2b61b44cbc Bluetooth: Add conn.h public header file
This one should be used for all public connection related APIs. Right
now it includes the reference counting and connection callback APIs.

Change-Id: Ib9b67e6115bb2e51322644757da1170851c3ca17
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 651e9a4b2e Bluetooth: Rename conn.h to conn_internal.h
We'll have a public conn.h header file soon, so to avoid confusion
rename the existing conn.h to conn_internal.h.

Change-Id: I5e5c89ec184a0a2de63e244b034c55a3d97af9dc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Jukka Rissanen 702a596594 net: Add kconf for networking
Change-Id: Id956b7debe4564613007d934636501c98ba1851d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 4c53ef0b93 net: Initialize the IP stack
Call relevant Contiki uIP functions to setup the internal
structures in the uIP stack.

Change-Id: If64df1543d66d0ff378c12f371aa2c06fb2fde0a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 6ba3a02eed net: uip: Avoid casting warning when accessing link local addr
The uip_ds6_nbr_get_ll() returns const addr but we need to
overwrite the addr so cast is needed here.

The const pointer returned by nbr-table.c:nbr_table_get_lladdr(),
which is called by uip_ds6_nbr_get_ll(), actually points to
neighbor cache which is dynamic and will never be stored in read
only memory, and thus is safe to cast to non-const.

Change-Id: Ifb47e4cb75054b0a9717304dc1d0bc497fee1e87
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 251a45b602 net: Use our network buffers instead of global ones in Contiki
This mega patch changes how Contiki uses buffers. In standard
Contiki there is only couple of static and global buffers.
This makes the stack non-reentrant and only usable in one
thread. This patch replaces the global buffer with buffer
supplied by caller (net_buf.h). The Contiki stack is still not
fully re-entrant after this (packet reassembly needs more TLC)
but it is a good start.

Change-Id: I63abc230b36b14f33f687d3ef64cffb0f3a69f5d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen da36c6371c net: Simple socket API introduced
The network context defines a network connection.

Change-Id: I29a186be6c9de9d824f10b6442fa1dfd3711d24d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 1cf34680cb net: Using correct defines to configure the net stack
Change-Id: Ia2f5f8e496d11c73125aa3e74c0f9ad48141c712
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 4f5723a5d0 net: Network initialization and tx/rx functionality
Functions to receive data from apps and transmit it to network, and
receive from network and pass data to apps.

Change-Id: I1b1b8c041e6c5e20294081d2cd403636e9909cdc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 3633410706 net: uip: Pack and alias network buffer related structs
We need to make sure that the structs that are cast to received
network buffer are packed. We also need to enable __may_alias__
attribute for these structs in order to avoid "dereferencing
type-punned pointer" warnings.

Change-Id: Iad65612fd176ed41d66c6fa05c50151001a406eb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen c6c89fbdc6 net: uip: Avoid compiler warning about unused variable
Variable called "initialized" is only needed if the nameserver
pool size is bigger than 1 (UIP_NAMESERVER_POOL_SIZE > 1).

Change-Id: I1bce30bd783f76e56f12b8e76b29c932ab5765af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen c5b936a7c8 net: uip: start_periodic_tcp_timer() not needed
The function start_periodic_tcp_timer(void) is only needed if one
has UIP_TCP or UIP_CONF_IP_FORWARD defined.

Change-Id: I5185bfbdb998ec3d6985681a85c26e094406c404
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen bb69910e2a net: uip: Added missing function prototypes to rtimer
Real timer implementation needs function prototypes.
This is just to satisfy the compiler. Needs more TLC.

Change-Id: I39baa7cfe69d28aa1f330089e22144df286c0a0d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen ce302ebc8b net: uip: Callback is only defined for RIME support
We do not need RIME so commenting out the callback call.

Change-Id: I09cd078a3741c6a8e5f4f8fd6387203e6107f218
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 1e8cbd99ee net: uip: psock.h is only needed for TCP connections
Comment out the psock.h include if TCP is not used.

Change-Id: I83e537b410b867a5ea30fb60c012521df351d05f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -05:00
Jukka Rissanen 75d4b3f0c2 net: Initial networking support
Base is from Contiki git tree at git://github.com/contiki-os/contiki.git
commit 6ac939bc58ea76aa37e9b86af55ad51cfc3434e9

This one does not do anything useful yet. It sets the baseline for
subsequent patches.

Change-Id: I7078c938dd59188beceaf47721afaa521d8bde1a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:14:20 -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
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 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