summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kraglak <marcin.kraglak@tieto.com>2014-01-10 10:18:25 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2014-01-16 12:23:15 +0200
commit287c075913ab28f01681f96d6312de63bf2f3091 (patch)
tree3573f458cc89f5df49f38aa1b66b2b8874abb77d
parent90fd2a2f98258749ae105c519c18e686b597ef8f (diff)
emulator/bthost: Ad implementation of rfcomm_ua_recv
This will handle ua responses in bthost.
-rw-r--r--emulator/bthost.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c
index afdc3a8b4..59a6b8d67 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1552,6 +1552,41 @@ static void rfcomm_ua_recv(struct bthost *bthost, struct btconn *conn,
struct l2conn *l2conn, const void *data,
uint16_t len)
{
+ const struct rfcomm_cmd *hdr = data;
+ uint8_t channel = RFCOMM_GET_CHANNEL(hdr->address);
+
+ if (!channel && RFCOMM_TEST_CR(RFCOMM_GET_TYPE(hdr->control)) &&
+ bthost->rfcomm_conn_data) {
+ uint8_t buf[14];
+ struct rfcomm_hdr *hdr = (struct rfcomm_hdr *)buf;
+ struct rfcomm_mcc *mcc = (struct rfcomm_mcc *)
+ (buf + sizeof(*hdr));
+ struct rfcomm_pn *pn_cmd = (struct rfcomm_pn *)
+ (buf + sizeof(*hdr)
+ + sizeof(*mcc));
+
+ memset(buf, 0, sizeof(buf));
+
+ hdr->address = RFCOMM_ADDR(1, 0);
+ hdr->control = RFCOMM_CTRL(RFCOMM_UIH, 0);
+ hdr->length = RFCOMM_LEN8(sizeof(*mcc) +
+ sizeof(*pn_cmd));
+
+ mcc->type = RFCOMM_MCC_TYPE(1, RFCOMM_PN);
+ mcc->length = RFCOMM_LEN8(sizeof(*pn_cmd));
+
+ pn_cmd->dlci = bthost->rfcomm_conn_data->channel * 2;
+ pn_cmd->priority = 7;
+ pn_cmd->ack_timer = 0;
+ pn_cmd->max_retrans = 0;
+ pn_cmd->mtu = 667;
+ pn_cmd->credits = 7;
+
+ buf[sizeof(*hdr) + sizeof(*mcc) + sizeof(*pn_cmd)] =
+ rfcomm_fcs(buf);
+
+ send_acl(bthost, conn->handle, l2conn->dcid, buf, sizeof(buf));
+ }
}
static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn,