forked from nuttx/nuttx-update
wireless: bluetooth: nxstyle fixes
various nxstyle fixes to fix the CI complains. Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
parent
0a673d759d
commit
e36d93f600
19 changed files with 414 additions and 323 deletions
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -436,13 +437,16 @@ static void att_req_destroy(FAR struct bt_att_req_s *req)
|
|||
memset(req, 0, sizeof(*req));
|
||||
}
|
||||
|
||||
static void send_err_rsp(struct bt_conn_s *conn, uint8_t req, uint16_t handle,
|
||||
static void send_err_rsp(struct bt_conn_s *conn,
|
||||
uint8_t req,
|
||||
uint16_t handle,
|
||||
uint8_t err)
|
||||
{
|
||||
struct bt_att_error_rsp_s *rsp;
|
||||
struct bt_buf_s *buf;
|
||||
|
||||
/* Ignore opcode 0x00 */
|
||||
|
||||
if (!req)
|
||||
{
|
||||
return;
|
||||
|
@ -510,7 +514,9 @@ static uint8_t att_mtu_req(struct bt_conn_s *conn, struct bt_buf_s *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t att_handle_rsp(struct bt_conn_s *conn, void *pdu, uint16_t len,
|
||||
static uint8_t att_handle_rsp(struct bt_conn_s *conn,
|
||||
void *pdu,
|
||||
uint16_t len,
|
||||
uint8_t err)
|
||||
{
|
||||
FAR struct bt_att_s *att = conn->att;
|
||||
|
@ -532,7 +538,8 @@ static uint8_t att_handle_rsp(struct bt_conn_s *conn, void *pdu, uint16_t len,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t att_mtu_rsp(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf)
|
||||
static uint8_t att_mtu_rsp(FAR struct bt_conn_s *conn,
|
||||
FAR struct bt_buf_s *buf)
|
||||
{
|
||||
FAR struct bt_att_s *att = conn->att;
|
||||
FAR struct bt_att_exchange_mtu_rsp_s *rsp;
|
||||
|
@ -628,7 +635,8 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
|
|||
|
||||
/* Fast forward to next item position */
|
||||
|
||||
data->u.info16 = bt_buf_extend(data->buf, sizeof(*data->u.info16));
|
||||
data->u.info16 = bt_buf_extend(data->buf,
|
||||
sizeof(*data->u.info16));
|
||||
data->u.info16->handle = BT_HOST2LE16(attr->handle);
|
||||
data->u.info16->uuid = BT_HOST2LE16(attr->uuid->u.u16);
|
||||
|
||||
|
@ -643,9 +651,11 @@ static uint8_t find_info_cb(FAR const struct bt_gatt_attr_s *attr,
|
|||
|
||||
/* Fast forward to next item position */
|
||||
|
||||
data->u.info128 = bt_buf_extend(data->buf, sizeof(*data->u.info128));
|
||||
data->u.info128 = bt_buf_extend(data->buf,
|
||||
sizeof(*data->u.info128));
|
||||
data->u.info128->handle = BT_HOST2LE16(attr->handle);
|
||||
memcpy(data->u.info128->uuid, attr->uuid->u.u128,
|
||||
memcpy(data->u.info128->uuid,
|
||||
attr->uuid->u.u128,
|
||||
sizeof(data->u.info128->uuid));
|
||||
|
||||
return att->mtu - data->buf->len > sizeof(*data->u.info128) ?
|
||||
|
@ -852,7 +862,8 @@ static uint8_t att_find_type_req(FAR struct bt_conn_s *conn,
|
|||
return att_find_type_rsp(conn, start_handle, end_handle, value, data->len);
|
||||
}
|
||||
|
||||
static bool uuid_create(FAR struct bt_uuid_s *uuid, FAR struct bt_buf_s *data)
|
||||
static bool uuid_create(FAR struct bt_uuid_s *uuid,
|
||||
FAR struct bt_buf_s *data)
|
||||
{
|
||||
if (data->len > sizeof(uuid->u.u128))
|
||||
{
|
||||
|
@ -1149,14 +1160,19 @@ static uint8_t att_read_req(FAR struct bt_conn_s *conn,
|
|||
|
||||
wlinfo("handle 0x%04x\n", handle);
|
||||
|
||||
return att_read_rsp(conn, BT_ATT_OP_READ_REQ, BT_ATT_OP_READ_RSP, handle, 0);
|
||||
return att_read_rsp(conn,
|
||||
BT_ATT_OP_READ_REQ,
|
||||
BT_ATT_OP_READ_RSP,
|
||||
handle,
|
||||
0);
|
||||
}
|
||||
|
||||
static uint8_t att_read_blob_req(FAR struct bt_conn_s *conn,
|
||||
FAR struct bt_buf_s *data)
|
||||
{
|
||||
FAR struct bt_att_read_blob_req_s *req;
|
||||
uint16_t handle, offset;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
|
||||
req = (FAR void *)data->data;
|
||||
|
||||
|
@ -1362,7 +1378,8 @@ static uint8_t att_read_group_req(FAR struct bt_conn_s *conn,
|
|||
* shall not be used in the ATT Read By Group Type Request.
|
||||
*/
|
||||
|
||||
if (bt_uuid_cmp(&uuid, &g_primary_uuid) && bt_uuid_cmp(&uuid, &g_secondary_uuid))
|
||||
if (bt_uuid_cmp(&uuid, &g_primary_uuid) &&
|
||||
bt_uuid_cmp(&uuid, &g_secondary_uuid))
|
||||
{
|
||||
send_err_rsp(conn, BT_ATT_OP_READ_GROUP_REQ, start_handle,
|
||||
BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE);
|
||||
|
@ -1382,7 +1399,8 @@ static uint8_t write_cb(FAR const struct bt_gatt_attr_s *attr,
|
|||
|
||||
/* Check for write support and flush support in case of prepare */
|
||||
|
||||
if (!attr->write || (data->op == BT_ATT_OP_PREPARE_WRITE_REQ && !attr->flush))
|
||||
if (!attr->write ||
|
||||
(data->op == BT_ATT_OP_PREPARE_WRITE_REQ && !attr->flush))
|
||||
{
|
||||
data->err = BT_ATT_ERR_WRITE_NOT_PERMITTED;
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
@ -1398,7 +1416,11 @@ static uint8_t write_cb(FAR const struct bt_gatt_attr_s *attr,
|
|||
|
||||
/* Read attribute value and store in the buffer */
|
||||
|
||||
write = attr->write(data->conn, attr, data->value, data->len, data->offset);
|
||||
write = attr->write(data->conn,
|
||||
attr,
|
||||
data->value,
|
||||
data->len,
|
||||
data->offset);
|
||||
if (write < 0 || write != data->len)
|
||||
{
|
||||
data->err = err_to_att(write);
|
||||
|
@ -1528,6 +1550,7 @@ static uint8_t att_prepare_write_req(FAR struct bt_conn_s *conn,
|
|||
BT_ATT_OP_PREPARE_WRITE_RSP, handle, offset,
|
||||
data->data, data->len);
|
||||
}
|
||||
|
||||
typedef CODE uint8_t
|
||||
(*bt_gatt_attr_func_t)(FAR const struct bt_gatt_attr_s *attr,
|
||||
FAR void *user_data);
|
||||
|
@ -1832,8 +1855,9 @@ void bt_att_initialize(void)
|
|||
bt_l2cap_chan_register(&chan);
|
||||
}
|
||||
|
||||
FAR struct bt_buf_s *bt_att_create_pdu(FAR struct bt_conn_s *conn, uint8_t op,
|
||||
size_t len)
|
||||
FAR struct bt_buf_s *bt_att_create_pdu(FAR struct bt_conn_s *conn,
|
||||
uint8_t op,
|
||||
size_t len)
|
||||
{
|
||||
FAR struct bt_att_hdr_s *hdr;
|
||||
FAR struct bt_buf_s *buf;
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -615,7 +615,9 @@ void bt_conn_set_state(FAR struct bt_conn_s *conn,
|
|||
BT_NORMAL_PRIO);
|
||||
}
|
||||
|
||||
/* Release the reference we took for the very first state transition. */
|
||||
/* Release the reference we took for the very first state
|
||||
* transition.
|
||||
*/
|
||||
|
||||
bt_conn_release(conn);
|
||||
break;
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -115,7 +116,7 @@ struct bt_conn_s
|
|||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -169,7 +170,8 @@ void bt_conn_send(FAR struct bt_conn_s *conn, FAR struct bt_buf_s *buf);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct bt_conn_s *bt_conn_add(FAR const bt_addr_le_t *peer, uint8_t role);
|
||||
FAR struct bt_conn_s *bt_conn_add(FAR const bt_addr_le_t *peer,
|
||||
uint8_t role);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bt_conn_set_state
|
||||
|
@ -187,7 +189,8 @@ FAR struct bt_conn_s *bt_conn_add(FAR const bt_addr_le_t *peer, uint8_t role);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
void bt_conn_set_state(FAR struct bt_conn_s *conn, enum bt_conn_state_e state);
|
||||
void bt_conn_set_state(FAR struct bt_conn_s *conn,
|
||||
enum bt_conn_state_e state);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bt_conn_lookup_handle
|
||||
|
@ -301,18 +304,18 @@ FAR const bt_addr_le_t *bt_conn_get_dst(FAR const struct bt_conn_s *conn);
|
|||
* Name: bt_conn_security
|
||||
*
|
||||
* Description:
|
||||
* This function enable security (encryption) for a connection. If device is
|
||||
* already paired with sufficiently strong key encryption will be enabled. If
|
||||
* link is already encrypted with sufficiently strong key this function does
|
||||
* nothing.
|
||||
* This function enable security (encryption) for a connection.
|
||||
* If device is already paired with sufficiently strong key encryption will
|
||||
* be enabled. If link is already encrypted with sufficiently strong key
|
||||
* this function does nothing.
|
||||
*
|
||||
* If device is not paired pairing will be initiated. If device is paired and
|
||||
* keys are too weak but input output capabilities allow for strong enough keys
|
||||
* pairing will be initiated.
|
||||
* If device is not paired pairing will be initiated.
|
||||
* If device is paired and keys are too weak but input output capabilities
|
||||
* allow for strong enough keys pairing will be initiated.
|
||||
*
|
||||
* This function may return error if required level of security is not possible
|
||||
* to achieve due to local or remote device limitation (eg input output
|
||||
* capabilities).
|
||||
* This function may return error if required level of security is not
|
||||
* possible to achieve due to local or remote device limitation (eg input
|
||||
* output capabilities).
|
||||
*
|
||||
* Input Parameters:
|
||||
* conn - Connection object.
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -747,7 +748,9 @@ int bt_gatt_discover(FAR struct bt_conn_s *conn,
|
|||
|
||||
case BT_UUID_128:
|
||||
bt_buf_extend(buf, sizeof(params->uuid->u.u128));
|
||||
memcpy(req->value, params->uuid->u.u128, sizeof(params->uuid->u.u128));
|
||||
memcpy(req->value,
|
||||
params->uuid->u.u128,
|
||||
sizeof(params->uuid->u.u128));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -811,8 +814,8 @@ static void att_read_type_rsp(FAR struct bt_conn_s *conn, uint8_t err,
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* Convert characteristic data, bt_gatt_chrc and gatt_chrc_s have different
|
||||
* formats so the conversion have to be done field by field.
|
||||
/* Convert characteristic data, bt_gatt_chrc and gatt_chrc_s have
|
||||
* different formats so the conversion have to be done field by field.
|
||||
*/
|
||||
|
||||
value.properties = chrc->properties;
|
||||
|
@ -840,7 +843,8 @@ static void att_read_type_rsp(FAR struct bt_conn_s *conn, uint8_t err,
|
|||
continue;
|
||||
}
|
||||
|
||||
attr = (&(struct bt_gatt_attr_s)BT_GATT_CHARACTERISTIC(handle, &value));
|
||||
attr = (&(struct bt_gatt_attr_s)BT_GATT_CHARACTERISTIC(handle,
|
||||
&value));
|
||||
|
||||
if (params->func(attr, params) == BT_GATT_ITER_STOP)
|
||||
{
|
||||
|
@ -894,7 +898,8 @@ done:
|
|||
****************************************************************************/
|
||||
|
||||
int bt_gatt_discover_characteristic(FAR struct bt_conn_s *conn,
|
||||
FAR struct bt_gatt_discover_params_s *params)
|
||||
FAR struct bt_gatt_discover_params_s
|
||||
*params)
|
||||
{
|
||||
FAR struct bt_buf_s *buf;
|
||||
FAR struct bt_att_read_type_req_s *req;
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -175,7 +176,8 @@ static inline int bt_addr_cmp(FAR const bt_addr_t *a, FAR const bt_addr_t *b)
|
|||
return memcmp(a, b, sizeof(*a));
|
||||
}
|
||||
|
||||
static inline int bt_addr_le_cmp(FAR const bt_addr_le_t *a, FAR const bt_addr_le_t *b)
|
||||
static inline int bt_addr_le_cmp(FAR const bt_addr_le_t *a,
|
||||
FAR const bt_addr_le_t *b)
|
||||
{
|
||||
return memcmp(a, b, sizeof(*a));
|
||||
}
|
||||
|
@ -185,7 +187,8 @@ static inline void bt_addr_copy(FAR bt_addr_t *dst, FAR const bt_addr_t *src)
|
|||
memcpy(dst, src, sizeof(*dst));
|
||||
}
|
||||
|
||||
static inline void bt_addr_le_copy(FAR bt_addr_le_t *dst, FAR const bt_addr_le_t *src)
|
||||
static inline void bt_addr_le_copy(FAR bt_addr_le_t *dst,
|
||||
FAR const bt_addr_le_t *src)
|
||||
{
|
||||
memcpy(dst, src, sizeof(*dst));
|
||||
}
|
||||
|
|
|
@ -667,7 +667,9 @@ int btnet_ioctl(FAR struct net_driver_s *netdev, int cmd, unsigned long arg)
|
|||
}
|
||||
break;
|
||||
|
||||
/* SIOCBTSCANSTOP: Stop LE scanning and discard any buffered results. */
|
||||
/* SIOCBTSCANSTOP:
|
||||
* Stop LE scanning and discard any buffered results.
|
||||
*/
|
||||
|
||||
case SIOCBTSCANSTOP:
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: btnet_ioctl
|
||||
*
|
||||
* Description:
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -334,42 +335,42 @@ FAR struct bt_keys_s *bt_keys_find_irk(FAR const bt_addr_le_t * addr)
|
|||
}
|
||||
|
||||
bt_keys_foreach(&g_irks, cur, irk.next)
|
||||
{
|
||||
FAR struct bt_irk_s *irk = &(*cur)->irk;
|
||||
{
|
||||
FAR struct bt_irk_s *irk = &(*cur)->irk;
|
||||
|
||||
if (!bt_addr_cmp((bt_addr_t *) addr->val, &irk->rpa))
|
||||
{
|
||||
wlinfo("cached RPA %s for %s\n", bt_addr_str(&irk->rpa),
|
||||
bt_addr_le_str(&(*cur)->addr));
|
||||
return *cur;
|
||||
}
|
||||
if (!bt_addr_cmp((bt_addr_t *) addr->val, &irk->rpa))
|
||||
{
|
||||
wlinfo("cached RPA %s for %s\n", bt_addr_str(&irk->rpa),
|
||||
bt_addr_le_str(&(*cur)->addr));
|
||||
return *cur;
|
||||
}
|
||||
|
||||
if (bt_smp_irk_matches(irk->val, (bt_addr_t *) addr->val))
|
||||
{
|
||||
FAR struct bt_keys_s *match = *cur;
|
||||
if (bt_smp_irk_matches(irk->val, (bt_addr_t *) addr->val))
|
||||
{
|
||||
FAR struct bt_keys_s *match = *cur;
|
||||
|
||||
wlinfo("RPA %s matches %s\n", bt_addr_str(&irk->rpa),
|
||||
bt_addr_le_str(&(*cur)->addr));
|
||||
wlinfo("RPA %s matches %s\n", bt_addr_str(&irk->rpa),
|
||||
bt_addr_le_str(&(*cur)->addr));
|
||||
|
||||
bt_addr_copy(&irk->rpa, (bt_addr_t *) addr->val);
|
||||
bt_addr_copy(&irk->rpa, (bt_addr_t *) addr->val);
|
||||
|
||||
/* Move to the beginning of the list for faster future lookups. */
|
||||
/* Move to the beginning of the list for faster future lookups. */
|
||||
|
||||
if (match != g_irks)
|
||||
{
|
||||
/* Remove match from list */
|
||||
if (match != g_irks)
|
||||
{
|
||||
/* Remove match from list */
|
||||
|
||||
*cur = irk->next;
|
||||
*cur = irk->next;
|
||||
|
||||
/* Add match to the beginning */
|
||||
/* Add match to the beginning */
|
||||
|
||||
irk->next = g_irks;
|
||||
g_irks = match;
|
||||
}
|
||||
irk->next = g_irks;
|
||||
g_irks = match;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
wlinfo("No IRK for %s\n", bt_addr_le_str(addr));
|
||||
return NULL;
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -89,7 +89,9 @@
|
|||
# error CONFIG_IOB_BUFSIZE to small for max Bluetooth frame
|
||||
#endif
|
||||
|
||||
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
|
||||
/* TX poll delay = 1 seconds.
|
||||
* CLK_TCK is the number of clock ticks per second
|
||||
*/
|
||||
|
||||
#define TXPOLL_WDDELAY (1*CLK_TCK)
|
||||
|
||||
|
@ -136,7 +138,7 @@ struct btnet_driver_s
|
|||
static int btnet_advertise(FAR struct net_driver_s *netdev);
|
||||
static inline void btnet_netmask(FAR struct net_driver_s *netdev);
|
||||
|
||||
/* Bluetooth callback functions ***************************************/
|
||||
/* Bluetooth callback functions *********************************************/
|
||||
|
||||
/* L2CAP callbacks */
|
||||
|
||||
|
@ -499,8 +501,8 @@ static void btnet_hci_disconnected(FAR struct bt_conn_s *conn,
|
|||
|
||||
static int btnet_txpoll_callback(FAR struct net_driver_s *netdev)
|
||||
{
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
* been examined.
|
||||
/* If zero is returned, the polling will continue until all connections
|
||||
* have been examined.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
|
@ -793,8 +795,8 @@ static int btnet_txavail(FAR struct net_driver_s *netdev)
|
|||
static int btnet_addmac(FAR struct net_driver_s *netdev,
|
||||
FAR const uint8_t *mac)
|
||||
{
|
||||
/* Add the MAC address to the hardware multicast routing table. Not used
|
||||
* with Bluetooth.
|
||||
/* Add the MAC address to the hardware multicast routing table.
|
||||
* Not used with Bluetooth.
|
||||
*/
|
||||
|
||||
return -ENOSYS;
|
||||
|
@ -805,8 +807,8 @@ static int btnet_addmac(FAR struct net_driver_s *netdev,
|
|||
* Name: btnet_rmmac
|
||||
*
|
||||
* Description:
|
||||
* NuttX Callback: Remove the specified MAC address from the hardware multicast
|
||||
* address filtering
|
||||
* NuttX Callback: Remove the specified MAC address from the hardware
|
||||
* multicast address filtering
|
||||
*
|
||||
* Input Parameters:
|
||||
* netdev - Reference to the NuttX driver state structure
|
||||
|
@ -823,8 +825,8 @@ static int btnet_addmac(FAR struct net_driver_s *netdev,
|
|||
static int btnet_rmmac(FAR struct net_driver_s *netdev,
|
||||
FAR const uint8_t *mac)
|
||||
{
|
||||
/* Remove the MAC address from the hardware multicast routing table Not used
|
||||
* with Bluetooth.
|
||||
/* Remove the MAC address from the hardware multicast routing table
|
||||
* Not used with Bluetooth.
|
||||
*/
|
||||
|
||||
return -ENOSYS;
|
||||
|
@ -1112,9 +1114,10 @@ int bt_netdev_register(FAR const struct bt_driver_s *btdev)
|
|||
btnet_ifdown(netdev);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* Make sure the our single packet buffer is attached. We must do this before
|
||||
* registering the device since, once the device is registered, a packet may
|
||||
* be attempted to be forwarded and require the buffer.
|
||||
/* Make sure the our single packet buffer is attached.
|
||||
* We must do this before registering the device since, once the device is
|
||||
* registered, a packet may be attempted to be forwarded and require the
|
||||
* buffer.
|
||||
*/
|
||||
|
||||
priv->bd_dev.r_dev.d_buf = g_iobuffer.rb_buf;
|
||||
|
|
|
@ -127,7 +127,8 @@ int bt_queue_open(FAR const char *name, int oflags, int nmsgs,
|
|||
* Block until the next buffer is received on the queue.
|
||||
*
|
||||
* Input Parameters:
|
||||
* mqd - The message queue descriptor previously returned by bt_open_*queue.
|
||||
* mqd - The message queue descriptor previously returned by
|
||||
* bt_open_*queue.
|
||||
* buf - The location in which to return the received buffer.
|
||||
*
|
||||
* Returned Value:
|
||||
|
|
|
@ -109,7 +109,8 @@ int bt_queue_open(FAR const char *name, int oflags, int nmsgs,
|
|||
* Block until the next buffer is received on the queue.
|
||||
*
|
||||
* Input Parameters:
|
||||
* mqd - The message queue descriptor previously returned by bt_open_*queue.
|
||||
* mqd - The message queue descriptor previously returned by
|
||||
* bt_open_*queue.
|
||||
* buf - The location in which to return the received buffer.
|
||||
*
|
||||
* Returned Value:
|
||||
|
@ -140,6 +141,8 @@ int bt_queue_receive(mqd_t mqd, FAR struct bt_buf_s **buf);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int bt_queue_send(mqd_t mqd, FAR struct bt_buf_s *buf, unsigned int priority);
|
||||
int bt_queue_send(mqd_t mqd,
|
||||
FAR struct bt_buf_s *buf,
|
||||
unsigned int priority);
|
||||
|
||||
#endif /* __WIRELESS_BLUETOOTH_BT_QUEUE_H */
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -276,7 +277,7 @@ static const uint8_t g_key[] =
|
|||
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
|
||||
};
|
||||
|
||||
static const uint8_t g_M[] =
|
||||
static const uint8_t g_m[] =
|
||||
{
|
||||
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
|
||||
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
|
||||
|
@ -366,7 +367,8 @@ static int le_encrypt(const uint8_t key[16], const uint8_t plaintext[16],
|
|||
{
|
||||
FAR struct bt_hci_cp_le_encrypt_s *cp;
|
||||
FAR struct bt_hci_rp_le_encrypt_s *rp;
|
||||
FAR struct bt_buf_s *buf, *rsp;
|
||||
FAR struct bt_buf_s *buf;
|
||||
FAR struct bt_buf_s *rsp;
|
||||
int err;
|
||||
|
||||
wlinfo("key %s plaintext %s\n", h(key, 16), h(plaintext, 16));
|
||||
|
@ -451,9 +453,9 @@ static int smp_ah(FAR const uint8_t irk[16], FAR const uint8_t r[3],
|
|||
}
|
||||
|
||||
/* The output of the random address function ah is: ah(h, r) = e(k, r') mod
|
||||
* 2^24 The output of the security function e is then truncated to 24 bits by
|
||||
* taking the least significant 24 bits of the output of e as the result of
|
||||
* ah.
|
||||
* 2^24 The output of the security function e is then truncated to 24 bits
|
||||
* by taking the least significant 24 bits of the output of e as the result
|
||||
* of ah.
|
||||
*/
|
||||
|
||||
memcpy(out, res, 3);
|
||||
|
@ -503,7 +505,9 @@ static int smp_c1(FAR const uint8_t k[16], FAR const uint8_t r[16],
|
|||
|
||||
wlinfo("p2 %s\n", h(p2, 16));
|
||||
|
||||
xor_128((FAR struct uint128_s *)enc_data, (FAR struct uint128_s *)p2, (FAR struct uint128_s *)enc_data);
|
||||
xor_128((FAR struct uint128_s *)enc_data,
|
||||
(FAR struct uint128_s *)p2,
|
||||
(FAR struct uint128_s *)enc_data);
|
||||
return le_encrypt(k, enc_data, enc_data);
|
||||
}
|
||||
|
||||
|
@ -609,8 +613,8 @@ static uint8_t smp_pairing_req(FAR struct bt_conn_s *conn,
|
|||
|
||||
rsp = bt_buf_extend(rsp_buf, sizeof(*rsp));
|
||||
|
||||
/* For JustWorks pairing simplify rsp parameters. TODO: needs to be reworked
|
||||
* later on.
|
||||
/* For JustWorks pairing simplify rsp parameters.
|
||||
* TODO: needs to be reworked later on.
|
||||
*/
|
||||
|
||||
auth = (req->auth_req & BT_SMP_AUTH_MASK);
|
||||
|
@ -650,7 +654,9 @@ static uint8_t smp_send_pairing_confirm(FAR struct bt_conn_s *conn)
|
|||
FAR struct bt_buf_s *rsp_buf;
|
||||
int err;
|
||||
|
||||
rsp_buf = bt_smp_create_pdu(conn, BT_SMP_CMD_PAIRING_CONFIRM, sizeof(*req));
|
||||
rsp_buf = bt_smp_create_pdu(conn,
|
||||
BT_SMP_CMD_PAIRING_CONFIRM,
|
||||
sizeof(*req));
|
||||
if (!rsp_buf)
|
||||
{
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
|
@ -699,6 +705,7 @@ static uint8_t smp_pairing_rsp(FAR struct bt_conn_s *conn,
|
|||
smp->remote_dist &= rsp->resp_key_dist;
|
||||
|
||||
/* Store rsp for later use */
|
||||
|
||||
smp->prsp[0] = BT_SMP_CMD_PAIRING_RSP;
|
||||
memcpy(smp->prsp + 1, rsp, sizeof(*rsp));
|
||||
|
||||
|
@ -791,6 +798,7 @@ static uint8_t smp_pairing_random(FAR struct bt_conn_s *conn,
|
|||
uint8_t stk[16];
|
||||
|
||||
/* No need to store master STK */
|
||||
|
||||
err = smp_s1(smp->tk, smp->rrnd, smp->prnd, stk);
|
||||
if (err)
|
||||
{
|
||||
|
@ -798,6 +806,7 @@ static uint8_t smp_pairing_random(FAR struct bt_conn_s *conn,
|
|||
}
|
||||
|
||||
/* Rand and EDiv are 0 for the STK */
|
||||
|
||||
if (bt_conn_le_start_encryption(conn, 0, 0, stk))
|
||||
{
|
||||
wlerr("ERROR: Failed to start encryption\n");
|
||||
|
@ -824,6 +833,7 @@ static uint8_t smp_pairing_random(FAR struct bt_conn_s *conn,
|
|||
}
|
||||
|
||||
/* Rand and EDiv are 0 for the STK */
|
||||
|
||||
keys->slave_ltk.rand = 0;
|
||||
keys->slave_ltk.ediv = 0;
|
||||
|
||||
|
@ -858,6 +868,7 @@ static uint8_t smp_pairing_failed(FAR struct bt_conn_s *conn,
|
|||
}
|
||||
|
||||
/* return no error to avoid sending Pairing Failed in response */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -870,7 +881,8 @@ static void bt_smp_distribute_keys(FAR struct bt_conn_s *conn)
|
|||
keys = bt_keys_get_addr(&conn->dst);
|
||||
if (!keys)
|
||||
{
|
||||
wlerr("ERROR: Unable to look up keys for %s\n", bt_addr_le_str(&conn->dst));
|
||||
wlerr("ERROR: Unable to look up keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -932,7 +944,8 @@ static uint8_t smp_encrypt_info(FAR struct bt_conn_s *conn,
|
|||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->dst);
|
||||
if (!keys)
|
||||
{
|
||||
wlerr("ERROR: Unable to get keys for %s\n", bt_addr_le_str(&conn->dst));
|
||||
wlerr("ERROR: Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -955,7 +968,8 @@ static uint8_t smp_master_ident(FAR struct bt_conn_s *conn,
|
|||
keys = bt_keys_get_type(BT_KEYS_LTK, &conn->dst);
|
||||
if (!keys)
|
||||
{
|
||||
wlerr("ERROR: Unable to get keys for %s\n", bt_addr_le_str(&conn->dst));
|
||||
wlerr("ERROR: Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -993,7 +1007,8 @@ static uint8_t smp_ident_info(FAR struct bt_conn_s *conn,
|
|||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->dst);
|
||||
if (!keys)
|
||||
{
|
||||
wlerr("ERROR: Unable to get keys for %s\n", bt_addr_le_str(&conn->dst));
|
||||
wlerr("ERROR: Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1038,8 @@ static uint8_t smp_ident_addr_info(FAR struct bt_conn_s *conn,
|
|||
keys = bt_keys_get_type(BT_KEYS_IRK, &conn->dst);
|
||||
if (!keys)
|
||||
{
|
||||
wlerr("ERROR: Unable to get keys for %s\n", bt_addr_le_str(&conn->dst));
|
||||
wlerr("ERROR: Unable to get keys for %s\n",
|
||||
bt_addr_le_str(&conn->dst));
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1133,8 @@ static void bt_smp_receive(FAR struct bt_conn_s *conn,
|
|||
|
||||
if (buf->len != g_smp_handlers[hdr->code].expect_len)
|
||||
{
|
||||
wlerr("ERROR: Invalid len %u for code 0x%02x\n", buf->len, hdr->code);
|
||||
wlerr("ERROR: Invalid len %u for code 0x%02x\n",
|
||||
buf->len, hdr->code);
|
||||
err = BT_SMP_ERR_INVALID_PARAMS;
|
||||
}
|
||||
else
|
||||
|
@ -1274,7 +1291,9 @@ static void array_shift(FAR const uint8_t *in, FAR uint8_t *out)
|
|||
for (i = 15; i >= 0; i--)
|
||||
{
|
||||
out[i] = in[i] << 1;
|
||||
|
||||
/* previous byte */
|
||||
|
||||
out[i] |= overflow;
|
||||
overflow = in[i] & 0x80 ? 1 : 0;
|
||||
}
|
||||
|
@ -1290,12 +1309,18 @@ static int cmac_subkey(FAR const uint8_t *key, FAR uint8_t *k1,
|
|||
[0 ... 14] = 0x00,
|
||||
[15] = 0x87,
|
||||
};
|
||||
uint8_t zero[16] = { 0 };
|
||||
|
||||
uint8_t zero[16] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
uint8_t *tmp = zero;
|
||||
uint8_t l[16];
|
||||
int err;
|
||||
|
||||
/* L := AES-128(K, const_Zero) */
|
||||
|
||||
err = le_encrypt(key, zero, tmp);
|
||||
if (err)
|
||||
{
|
||||
|
@ -1307,27 +1332,35 @@ static int cmac_subkey(FAR const uint8_t *key, FAR uint8_t *k1,
|
|||
wlinfo("l %s\n", h(l, 16));
|
||||
|
||||
/* if MSB(L) == 0 K1 = L << 1 */
|
||||
|
||||
if (!(l[0] & 0x80))
|
||||
{
|
||||
array_shift(l, k1);
|
||||
|
||||
/* else K1 = (L << 1) XOR rb */
|
||||
}
|
||||
else
|
||||
{
|
||||
array_shift(l, k1);
|
||||
xor_128((FAR struct uint128_s *)k1, (FAR struct uint128_s *)rb, (FAR struct uint128_s *)k1);
|
||||
xor_128((FAR struct uint128_s *)k1,
|
||||
(FAR struct uint128_s *)rb,
|
||||
(FAR struct uint128_s *)k1);
|
||||
}
|
||||
|
||||
/* if MSB(K1) == 0 K2 = K1 << 1 */
|
||||
|
||||
if (!(k1[0] & 0x80))
|
||||
{
|
||||
array_shift(k1, k2);
|
||||
|
||||
/* else K2 = (K1 << 1) XOR rb */
|
||||
}
|
||||
else
|
||||
{
|
||||
array_shift(k1, k2);
|
||||
xor_128((FAR struct uint128_s *)k2, (struct uint128_s *FAR )rb, (FAR struct uint128_s *)k2);
|
||||
xor_128((FAR struct uint128_s *)k2,
|
||||
(struct uint128_s *FAR)rb,
|
||||
(FAR struct uint128_s *)k2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1399,11 +1432,13 @@ static int bt_smp_aes_cmac(FAR const uint8_t *key, FAR const uint8_t *in,
|
|||
if ((len % 16) == 0)
|
||||
{
|
||||
/* complete blocks */
|
||||
|
||||
flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* last block is not complete */
|
||||
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1502,25 +1537,25 @@ static int smp_aes_cmac_test(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
err = aes_test("Test aes-cmac0", g_key, g_M, 0, g_mac1);
|
||||
err = aes_test("Test aes-cmac0", g_key, g_m, 0, g_mac1);
|
||||
if (err)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
err = aes_test("Test aes-cmac16", g_key, g_M, 16, g_mac2);
|
||||
err = aes_test("Test aes-cmac16", g_key, g_m, 16, g_mac2);
|
||||
if (err)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
err = aes_test("Test aes-cmac40", g_key, g_M, 40, g_mac3);
|
||||
err = aes_test("Test aes-cmac40", g_key, g_m, 40, g_mac3);
|
||||
if (err)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
err = aes_test("Test aes-cmac64", g_key, g_M, 64, g_mac4);
|
||||
err = aes_test("Test aes-cmac64", g_key, g_m, 64, g_mac4);
|
||||
if (err)
|
||||
{
|
||||
return err;
|
||||
|
@ -1606,8 +1641,8 @@ int bt_smp_send_pairing_req(FAR struct bt_conn_s *conn)
|
|||
|
||||
req = bt_buf_extend(req_buf, sizeof(*req));
|
||||
|
||||
/* For JustWorks pairing simplify req parameters. TODO: needs to be reworked
|
||||
* later on
|
||||
/* For JustWorks pairing simplify req parameters.
|
||||
* TODO: needs to be reworked later on
|
||||
*/
|
||||
|
||||
req->auth_req = BT_SMP_AUTH_BONDING;
|
||||
|
@ -1623,6 +1658,7 @@ int bt_smp_send_pairing_req(FAR struct bt_conn_s *conn)
|
|||
memset(smp->tk, 0, sizeof(smp->tk));
|
||||
|
||||
/* Store req for later use */
|
||||
|
||||
smp->preq[0] = BT_SMP_CMD_PAIRING_REQ;
|
||||
|
||||
memcpy(smp->preq + 1, req, sizeof(*req));
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -171,7 +172,8 @@ begin_packed_struct struct bt_smp_security_request_s
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
bool bt_smp_irk_matches(FAR const uint8_t irk[16], FAR const bt_addr_t *addr);
|
||||
bool bt_smp_irk_matches(FAR const uint8_t irk[16],
|
||||
FAR const bt_addr_t *addr);
|
||||
int bt_smp_send_pairing_req(FAR struct bt_conn_s *conn);
|
||||
int bt_smp_send_security_req(FAR struct bt_conn_s *conn);
|
||||
int bt_smp_initialize(void);
|
||||
|
|
|
@ -12,30 +12,31 @@
|
|||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS
|
||||
* ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in a new issue