Commit Graph

1810 Commits

Author SHA1 Message Date
Genaro Saucedo Tejada 4dc8078435 fix: net samples no longer include unneeded 802.15.4 files
Some samples were including nullsec.c, simplerdc.c and
framer-nullmac.c, those files are not needed but introduce some
symbol dependencies, causing link to fail when optimization is not
-Os, e.g. when compiling with CONFIG_DEBUG.

Change-Id: Id227470a4517e8e2c3b9af942b0893783075cd40
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
2016-09-12 12:29:09 +00:00
Jukka Rissanen 33d92af1cf net: Initial trickle algorithm support for legacy IP stack
This commit only provides the Trickle algorithm support.
Some other entity must call its functions in order to be
useful.

Fixes: ZEP-627

Change-Id: Ice1fcfe9c57269309eeab06eab000622662e2929
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-09-12 02:00:12 +00:00
Vinicius Costa Gomes f0882c2c80 net/buf: Add missing line break in debug statement
Without this line break, when CONFIG_NET_BUF_DEBUG is enabled, the
output may get confusing.

Change-Id: Ic467511f1dbbd283710f51ef14f94e0269c7c0ea
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-08 11:29:29 +00:00
Jaganath Kanakkassery 028bf3fb88 Bluetooth: RFCOMM: Modify bt_rfcomm_dlc() to return dlc
Currently bt_rfcomm_dlc() is returning error code and dlc is returned
as output param. Since caller does not need to check error, it can
return NULL if some error happens

Change-Id: I86e85b67545edb960b4b745267e6645017373bf6
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 07:22:38 +00:00
Jaganath Kanakkassery 2df4bf6237 Bluetooth: RFCOMM: Implement TX flow control
Data sent by user will be queued in a FIFO. A TX fiber will be
started for each DLC which process this FIFO and write to L2CAP.
Fiber will sleep in two scenarios - no buffer in FIFO, no TX
credit. Credit is handled using semaphore. So if credit is 0
then fiber will wait on semaphore and will be scheduled when
it receives credit.

Change-Id: Id6e796eed594b28d6fb6e4259d3ed52634db9335
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 07:22:32 +00:00
Vinayak Chettimada d72b06da56 Bluetooth: GATT: Fix ccc cfg leak
ccc cfg is allocated when a peer updates a ccc value. This
fix will retain a cfg only if the new value is not default.

Change-id: I586082818145e43c771a6fccdb0bf2b3cecdd30c
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 05:19:45 +00:00
Vinayak Chettimada 73808e25d6 Bluetooth: GAP: Support multiple peripheral role connections
Fix the use of BT_DEV_KEEP_ADVERTISING and BT_DEV_ADVERTISING
so as to permit multiple peripheral role connections if the
controller supports Bluetooth Spec. v4.2 LE Topology.

Change-Id: Ia363181754cb788c13e9050e5fe5416201593c07
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Carles Cufi 49583b10d0 Bluetooth: HCI: Rename cmd complete struct
For consistency, add the bt_ prefix to
hci_evt_cmd_complete.

Jira: ZEP-726

Change-Id: I0deb9f12913991bf52ccffc8c85b86c83da1c045
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Luiz Augusto von Dentz 4f418a6b42 Bluetooth: GATT: Fix unaligned accesses
Use net_buf helper whenever accessing data by reference.

Change-Id: I3c7eb3af33a3d22741f73c094fb4a39e3e3d3440
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-07 08:17:26 +03:00
Kaustav Dey Biswas 68e58af67e Bluetooth: UUID: Add 32bit UUID support
This adds helper support for handling 32bit UUIDs

Change-Id: I4874b5f092bdbe30039b8031485bf856e4268f2a
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 3b61beca20 Bluetooth: GATT: Fix unaligned access to CCC value
The CCC value behind the 'buf' pointer in bt_gatt_attr_write_ccc() may
not be appropriately aligned. It should therefore be accessed with
sys_get_le16() instead of sys_le16_to_cpu(). This also eliminates the
need of a separate uint16_t helper variable in the function.

Change-Id: I93d50f894e877f25ec6ed2f576cf6bf6d440190b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Vinayak Chettimada 1553ccc492 Bluetooth: Add LE read supported states
To fully support BT Spec. v4.2 LE Topology use LE read supported
states HCI command to find the supported states in the
controller.

Change-id: I6b4cf4cbefdff44e51bb0a4242e0aef3755f43db
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery ca938e0dcd Bluetooth: RFCOMM: Fix BT_RFCOMM_BUF_SIZE to include FCS and len
Profiles uses this helper to allocate net buf, so it should include
2 byte length in RFCOMM header and FCS which will be appended in the
tail by RFCOMM.

Change-Id: I0118eb9b0e0ab1daa9267c165af62bb50f1575d9
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 6ffbf795ce Bluetooth: RFCOMM: Introduce Kconfig for max L2CAP MTU
Intorduces CONFIG_BLUETOOTH_RFCOMM_L2CAP_MTU which sets default as
CONFIG_BLUETOOTH_L2CAP_IN_MTU since it will make sure that RFCOMM
frames can be fit in ACL buffer to avoid fragmentation and at the
same time profiles can utilize the size of ACL buffer while configuring
RFCOMM MTU.

Once fragementation is handled, this can be configured to higher values
based on the profiles supported and its L2CAP PDU size requirement.

The maximum value possible is 32676 which is max RFCOMM frame size
given in the spec.

Change-Id: I57e178ea4da846243067c3e072d1f4c5536a3ee3
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 68adceed5e Bluetooth: Move reading extended features to BR/EDR section of init
Those are needed only for BR/EDR and in fact was read was never issued
on LE only system due to pages count being 1 in such case.

Change-Id: I8facb77edb9cd03b392034423d8bb261f685b725
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 6198f07637 Bluetooth: RFCOMM: Introduce helper to create rfcomm pdu
Profiles can use this helper to create buffer which reserves the
headroom for rfcomm, l2cap and acl headers

Change-Id: I22f97b54423d66fe0c133a8e9903b652fb6a6854
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Vinayak Chettimada f77d06ae09 Bluetooth: GATT: Fix notifications to non-bonded peers
GATT implementation fixed so that two or more non-bonded peers
can now independently enable/disable notification and/or
indications; and subsequently receive them too.

Change-id: Ifae78297b6ba13f8ea3db58694302bb7f3449e97
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-07 08:17:26 +03:00
Johan Hedberg 91c7d938e3 Bluetooth: Kconfig: Be consistent with the use of tabs vs spaces
The most common convention is a space between "config" and the
variable name.

Change-Id: I0f97d5fee56b7db1808dcf07f21016b11f821fa3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 5d8f6bf2eb Bluetooth: Kconfig: Add default for L2CAP_IN_MTU if BREDR is enabled
Currently set value as 200 since the HFP needs atleast 132 for CIND
response. AVDTP requirement is less that that and SDP protocol can
handle partial responses.

Note that currently only A2DP offload is considered and for non offload
case (which will need a seperate Kconfig anyway) another default will be
required.

Change-Id: Ief0854365ec47baf754b0a657203e1dc93f0d154
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 9966337daf Bluetooth: ATT: Fix usage of unsupported %zu format specifier
The Zephyr libc doesn't currently support %zu (it just produces
garbage), so use %u instead.

Change-Id: Ifcaaec79e21f600f00a9336b5267d2d1654adfd7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 50318d2e4f Bluetooth: Clean up feature test macros
The lmp_*_capable() macros were neither following the appropriate name
space (BT_*) nor the appropriate style (macros should be upper-case).
Introduce a new BT_FEAT_TEST() macro which gives a clearer mapping to
the feature tables found in the core specification. Each specific
feature test macro is now also named with the appropriate BT_FEAT_*
prefix.

Change-Id: Ia6b18b066927908f9bda646e737e63d46a1d17df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 8d6b12f235 Bluetooth: Fix feature page count for single-mode configuration
Single-mode controllers only have features page 0 (plus the LE
features), so allocating three pages in struct bt_dev is a waste of
space.

Change-Id: Idad73ded12bd153776019d0e5f8adbdb74724845
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 0af62d309f Bluetooth: Fix reading local features
Page 0 should be read with the "non-ext" HCI command whereas pages 1-n
with the extended features command (and only if the controller
supports extended features).

Change-Id: I1ddddd367e6883eb83e98983b545f3ffb6159e97
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 00eda80c59 Bluetooth: Make lmp_ext_feat_capable() more generic
Make is possible to use lmp_ext_feat_capable() both for local as well
as remote features.

Change-Id: I05bb6a25303c0dd2f5e0bbc4f7f412210f668aa3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 29cbaa864d Bluetooth: Enable Secure Connections if supported
Enable BR/EDR Secure Connections if Write Secure Connections Host
Support Command is supported in controller.

Change-Id: Ic0c989217be3cd95e5c0ce1ae2b18d3557c774b8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc a5ab11708e Bluetooth: Read local extended features on init
Use Read Local Extended Features command to read local features and
extended local features on init.

Change-Id: I4c8594783895f439af36214881aeff24e116e783
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 0bb0acc8a7 Bluetooth: Add support for P256 Link Keys
If P256 Link Key is received in Link Key notification event is should
be marked appropriately.

Change-Id: I09c2f5560d95dd360ef046330e5d85451b02821c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Szymon Janc d48f19d3cc Bluetooth: Refactor Link Key notification event handling
Make sure that Link Key flags are always synced with key type received
in event. Also make sure that no garbage data is stored in key value.

Change-Id: I06d91da19a7c3497a3051d66f43c0d22f24f5e7d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa b082216e2f Bluetooth: L2CAP: Implement connect command on BR/EDR
Adds functionality to do connect to remote PSM. Connecting to remote
PSM other than SDP when both support SSP involves raising security
to at least BT_SECURITY_MEDIUM before any CoC traffic on L2CAP layer.
If connection response is send back with status 'pending' it means
remote doing additional job, so restarts RTX timer. If the command
timer is fired detach the apps channel from connection and make it
ready for reuse.

Change-Id: I81f57bc2f5738754f872ce52cb25027db6db5ccf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery f598f3f3f6 Bluetooth: RFCOMM: Implement send data API
Sends the data to l2cap after adding rfcomm header. Profile should
reserve the head room for rfcomm, l2cap and hci headers. Data length
should not be more than dlc mtu.

Flow control is not included in this patch

< ACL Data TX: Handle 256 flags 0x00 dlen 38
      Channel: 64 len 34 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x09 cr 0 dlci 0x02
         Control: 0xef poll/final 0
         Length: 30
         FCS: 0x40
        ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff ff ff ff ff ff ff 40

Change-Id: Ib97dbf85e236a5f75fda6037bb75bc6be00b9dc7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 3931b402e8 Bluetooth: Kconfig: Remove unnecessary default conditionals
There should always be one unconditional default and then a
conditional for each exception.

Change-Id: If1043c70eaae631c0a46c0af065a77199eb8e91b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery cb3120d440 Bluetooth: L2CAP: Disable fragmentation of rx pdu
Currently if rx mtu is more than ACL in buffer size, then controller
fragments the data (if its more than buffer size) but recombination
in host is failing because of buf limiation (and seeing below error)
"Not enough buffer space for L2CAP data" in bt_conn_recv()

Change-Id: Iac0455eb1848fa228fce88fec9810d20542b0759
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Luiz Augusto von Dentz 50997f2ccd Bluetooth: GATT: Add queuing support
This adds queueing support for requests that requires a response making
it simpler to use the API. The storage is keep in the parameters of the
request so it is up to the application to define how many can be queued
but in case the application don't want a request to block waiting for
a buffer it can use BLUETOOTH_ATT_REQ_COUNT to control the available
buffers which is recommended in case the requests will be sent from the
RX fiber.

Change-Id: I407c3982a7ecdc4a9eff7172d9d0addd46949783
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 5ff76656b0 Bluetooth: Fix typo in code comment
Change-Id: Ic1901fd6b8ab6c2e8f4dc20a60d29e6f19671fef
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery febdf2dc0b Bluetooth: RFCOMM: Fix cr bit of address in MSC response
cr bit of address in MSC should be always 1 irrespective of whether it
is command or response. Command/Response would be identified by cr bit
of msg type in UIH

Change-Id: I8e8b8446fa98aa07269953cfb6e54be915d4aba7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 1c34f1e322 Bluetooth: L2CAP: Fix reset channel state context
Since now CoC on each transport has registered own 'destroy' handler
it can be used to reset per transport L2CAP channel context. Then when
bt_l2cap_chan_del() API is called there's no more need to use
preprocessor to handle reset channel's state.

Change-Id: I1abb5d380a31ec54e2b6613d994ffdb0f94b93a5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Arkadiusz Lichwa 0569ef32b9 Bluetooth: L2CAP: Refactor connection security handler
Makes main security handler verifying incoming connection request on
BR/EDR transport to be more descriptive and readable. Its output
result is now more fine-grained.

Change-Id: Ifc3960bd16219e92f6e61700c61605cf05e4d6d3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 407013f3c7 Bluetooth: RFCOMM: Handle data and credit from peer
Data is transferred in UIH frame to a valid dlci. In this case the
meaning of PF bit is different, if PF bit is 1 then credit is there
in the frame otherwise no credit (only user data). So basically UIH
frame to a valid dlci can be "Only data, Only credit, both credit and
data"

Only credit
> ACL Data RX: Handle 256 flags 0x02 dlen 9
      Channel: 64 len 5 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0xff poll/final 1
         Length: 0
         FCS: 0x86
         Credits: 33
        86

Only data
> ACL Data RX: Handle 256 flags 0x02 dlen 9
      Channel: 64 len 5 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0xef poll/final 0
         Length: 1
         FCS: 0x9a
        ff 9a

Change-Id: Iaa48f9aa022f33e1a1217f19dc59ce761cfeac74
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery d6af0ef091 Bluetooth: RFCOMM: Perform MSC transaction after dlc
MSC (Modem status command) is used to convey RS-232 control and break
signals. This shall be sent prior to any user data after dlc. Remote
also would have sent it which is handled in this patch

This has meaning only if a port emulation entity is there on top (which
is not there in zephyr right now). So currently v24 signal is hard
coded like below.
DV = 1 IC = 0 RTR = 1 RTC = 1 FC = 0 EXT = 0

< ACL Data TX: Handle 256 flags 0x00 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0xaa
         MCC Message type: Modem Status Command CMD (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 256 flags 0x02 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0x70
         MCC Message type: Modem Status Command CMD (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
< ACL Data TX: Handle 256 flags 0x00 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0xaa
         MCC Message type: Modem Status Command RSP (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 256 flags 0x02 dlen 12
      Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 4
         FCS: 0x70
         MCC Message type: Modem Status Command RSP (0x38)
           Length: 2
           dlci 2
           fc 0 rtc 1 rtr 1 ic 0 dv 1

Change-Id: Iab06f12de2f2357485309eb622c8c5e13db7011c
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery b773edc053 Bluetooth: RFCOMM: Move rfcomm_make_uih_msg() up
It has to be used to send MSC from rfcomm_dlc_connected()

Change-Id: I96fa161359c54d31e8cccb9fa3aa749465308f61
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery d363b6896c Bluetooth: RFCOMM: Handle incoming dlc request
Handles SABM request to a valid dlci and sends UA response. If PN is
not negotiated for this dlci prior, then accept callback will be invoked
to profile. Dlc will be connected at this point and user can start
sending data over this dlc

> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                                        [hci0] 210.138443
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x59
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                                        [hci0] 210.140102
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0x92

Change-Id: I6bf5efb811d3ca5b106c9dff67d3a50a74818956
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery ab96eae52d Bluetooth: RFCOMM: Handle PN request
PN (Parameter negotiation) is used to negotiate parameters like mtu.
Initial credit for flow control is also sent in PN. If the dlci to which
PN requested is not found in the dlc list then it will be treated as
incoming dlc request and accept callback will be called to profile.
Dlc mtu has to be set by profile (before it returns dlc) which will be
negotiated with remote. But the final mtu will be min of mtu provided
by profile, mtu sent by remote, and session mtu

> ACL Data RX: Handle 256 flags 0x02 dlen 18                                                                                                                                       [hci0] 210.108444
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
           Length: 8
           dlci 2 frame_type 0 credit_flow 15 pri 7
           ack_timer 0 frame_size 122 max_retrans 0 credits 7
< ACL Data TX: Handle 256 flags 0x00 dlen 18                                                                                                                                       [hci0] 210.111452
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x01 cr 0 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0xaa
         MCC Message type: DLC Parameter Negotiation RSP (0x20)
           Length: 8
           dlci 2 frame_type 0 credit_flow 14 pri 0
           ack_timer 0 frame_size 30 max_retrans 0 credits 7

Change-Id: Ifd466db6b3b868d04e38db02ebad6e47ab2da030
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 7eec8a4442 Bluetooth: RFCOMM: Handle signalling connection request
Handles the SABM request to dlci 0 and sends UA response which makes
session state as CONNECTED. Session mtu is set as min of l2cap tx and
rx mtu since in rfcomm mtu is symmetric (unlike L2CAP). This means that
mtu of all the dlcs should be less than or equal to its session mtu so
that each rfcomm frame can be contained in single l2cap pdu.

> ACL Data RX: Handle 256 flags 0x02 dlen 8                                                                                                                                        [hci0] 210.078442
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Set Async Balance Mode (SABM) (0x2f)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x3f poll/final 1
         Length: 0
         FCS: 0x1c
< ACL Data TX: Handle 256 flags 0x00 dlen 8                                                                                                                                        [hci0] 210.080586
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Ack (UA) (0x63)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0xd7

This also inntroduces table and functions to calculate and
check FCS. These are taken from GSM 07.10 TS 101 369 V6.5.0

Change-Id: Ief5822b7f9350f50e700ff4f460c818a5a1068b7
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery a816142687 Bluetooth: RFCOMM: Init buffer for outgoing signalling packets
Buffer size is currently set as rfcomm min mtu

Change-Id: Ie8fd3f1cef9d6d9b62d5aca272f0030181175460
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Andrei Emeltchenko 6ab1b9cdc4 Bluetooth: Add RAW API interface to Bluetooth
HCI RAW channel API is intended to expose HCI interface to the remote
entity. The local Bluetooth controller gets owned by the remote entity
and host Bluetooth stack is not used. RAW API provides direct access
to packets which are sent and received by Bluetooth HCI drivers.

Change-Id: I4ba2b7ca2c2b0d6c5de6ef1f231d1c5b82125e09
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-09-07 08:17:26 +03:00
Szymon Janc 017586707e Bluetooth: Set BR/EDR device name on init
This adds support for setting default BR/EDR name on init. For now
this is just static configuration but can be extended later on
to allow runtime configuration if requested.

< HCI Command: Write Local Name (0x03|0x0013) plen 248
        Name: Zephyr
> HCI Event: Command Complete (0x0e) plen 4
      Write Local Name (0x03|0x0013) ncmd 1
        Status: Success (0x00)

Change-Id: I59ecfc2be8e55c6f90cdb0f12c6fed7f7ce976f8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 7859ffeab0 Bluetooth: RFCOMM: Implement Register Server channel API
Profiles can use this API to register the RFCOMM server channel.
DLC structure which represents individual connnection on a particular
server channel has to be defined in the profile and provide it in
accept callback.

Change-Id: I14e607ca65a29f29389deb2ac5d0658f5cd92883
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery b4aa810f0c Bluetooth: RFCOMM: Initialize and register to L2CAP
Initialize RFCOMM layer and register PSM to L2CAP. RFCOMM session
which represents the signalling context is also defined. Only one
signalling context will be there per ACL connection and hence l2cap
chan object is embedded into session.

Change-Id: I9b0931b51753571f5da40c76f4b8a7d5f93546fb
Origin: Original
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00
Johan Hedberg 71680a6053 Bluetooth: Fix race condition when initializing ECC FIFO
First access to the ecc_queue may happen either from an application
task (calling bt_enable()) or from the internal ECC task. Since we
don't have control of this we need to do conditional initialization of
the FIFO.

Change-Id: I5c96782ec7a6f829da0fe15e13817934319381df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-09-07 08:17:26 +03:00
Jaganath Kanakkassery 2f13527766 Bluetooth: L2CAP: Implement bt_l2cap_br_chan_send()
Sends the packet to HCI using bt_l2cap_send()

Change-Id: Iaec86ddc53adc632b597237a248acbd2e61fe4f6
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-07 08:17:26 +03:00