Lines Matching +full:host +full:- +full:side
10 * http://www.apache.org/licenses/LICENSE-2.0
33 #include "host/ble_hs.h"
34 #include "host/ble_hs_adv.h"
35 #include "host/ble_uuid.h"
36 #include "host/ble_att.h"
37 #include "host/ble_gap.h"
38 #include "host/ble_gatt.h"
39 #include "host/ble_store.h"
40 #include "host/ble_sm.h"
153 msg, conn_handle, error->status, error->att_handle); in btshell_print_error()
162 if (fields->flags != 0) { in btshell_print_adv_fields()
163 console_printf(" flags=0x%02x:\n", fields->flags); in btshell_print_adv_fields()
165 if (!(fields->flags & BLE_HS_ADV_F_DISC_LTD) && in btshell_print_adv_fields()
166 !(fields->flags & BLE_HS_ADV_F_DISC_GEN)) { in btshell_print_adv_fields()
167 console_printf(" Non-discoverable mode\n"); in btshell_print_adv_fields()
170 if (fields->flags & BLE_HS_ADV_F_DISC_LTD) { in btshell_print_adv_fields()
174 if (fields->flags & BLE_HS_ADV_F_DISC_GEN) { in btshell_print_adv_fields()
178 if (fields->flags & BLE_HS_ADV_F_BREDR_UNSUP) { in btshell_print_adv_fields()
183 if (fields->uuids16 != NULL) { in btshell_print_adv_fields()
185 fields->uuids16_is_complete ? "" : "in"); in btshell_print_adv_fields()
186 for (i = 0; i < fields->num_uuids16; i++) { in btshell_print_adv_fields()
187 print_uuid(&fields->uuids16[i].u); in btshell_print_adv_fields()
193 if (fields->uuids32 != NULL) { in btshell_print_adv_fields()
195 fields->uuids32_is_complete ? "" : "in"); in btshell_print_adv_fields()
196 for (i = 0; i < fields->num_uuids32; i++) { in btshell_print_adv_fields()
197 print_uuid(&fields->uuids32[i].u); in btshell_print_adv_fields()
203 if (fields->uuids128 != NULL) { in btshell_print_adv_fields()
205 fields->uuids128_is_complete ? "" : "in"); in btshell_print_adv_fields()
206 for (i = 0; i < fields->num_uuids128; i++) { in btshell_print_adv_fields()
207 print_uuid(&fields->uuids128[i].u); in btshell_print_adv_fields()
213 if (fields->name != NULL) { in btshell_print_adv_fields()
215 fields->name_is_complete ? "" : "in"); in btshell_print_adv_fields()
216 console_write((char *)fields->name, fields->name_len); in btshell_print_adv_fields()
220 if (fields->tx_pwr_lvl_is_present) { in btshell_print_adv_fields()
221 console_printf(" tx_pwr_lvl=%d\n", fields->tx_pwr_lvl); in btshell_print_adv_fields()
224 if (fields->slave_itvl_range != NULL) { in btshell_print_adv_fields()
226 print_bytes(fields->slave_itvl_range, in btshell_print_adv_fields()
231 if (fields->svc_data_uuid16 != NULL) { in btshell_print_adv_fields()
233 print_bytes(fields->svc_data_uuid16, in btshell_print_adv_fields()
234 fields->svc_data_uuid16_len); in btshell_print_adv_fields()
238 if (fields->public_tgt_addr != NULL) { in btshell_print_adv_fields()
240 u8p = fields->public_tgt_addr; in btshell_print_adv_fields()
241 for (i = 0; i < fields->num_public_tgt_addrs; i++) { in btshell_print_adv_fields()
248 if (fields->appearance_is_present) { in btshell_print_adv_fields()
249 console_printf(" appearance=0x%04x\n", fields->appearance); in btshell_print_adv_fields()
252 if (fields->adv_itvl_is_present) { in btshell_print_adv_fields()
253 console_printf(" adv_itvl=0x%04x\n", fields->adv_itvl); in btshell_print_adv_fields()
256 if (fields->svc_data_uuid32 != NULL) { in btshell_print_adv_fields()
258 print_bytes(fields->svc_data_uuid32, in btshell_print_adv_fields()
259 fields->svc_data_uuid32_len); in btshell_print_adv_fields()
263 if (fields->svc_data_uuid128 != NULL) { in btshell_print_adv_fields()
265 print_bytes(fields->svc_data_uuid128, in btshell_print_adv_fields()
266 fields->svc_data_uuid128_len); in btshell_print_adv_fields()
270 if (fields->uri != NULL) { in btshell_print_adv_fields()
272 print_bytes(fields->uri, fields->uri_len); in btshell_print_adv_fields()
276 if (fields->mfg_data != NULL) { in btshell_print_adv_fields()
278 print_bytes(fields->mfg_data, fields->mfg_data_len); in btshell_print_adv_fields()
294 return -1; in btshell_conn_find_idx()
303 if (idx == -1) { in btshell_conn_find()
317 SLIST_FOREACH(svc, &conn->svcs, next) { in btshell_svc_find_prev()
318 if (svc->svc.start_handle >= svc_start_handle) { in btshell_svc_find_prev()
337 svc = SLIST_FIRST(&conn->svcs); in btshell_svc_find()
342 if (svc != NULL && svc->svc.start_handle != svc_start_handle) { in btshell_svc_find()
357 SLIST_FOREACH(svc, &conn->svcs, next) { in btshell_svc_find_range()
358 if (svc->svc.start_handle <= attr_handle && in btshell_svc_find_range()
359 svc->svc.end_handle >= attr_handle) { in btshell_svc_find_range()
373 while ((dsc = SLIST_FIRST(&chr->dscs)) != NULL) { in btshell_chr_delete()
374 SLIST_REMOVE_HEAD(&chr->dscs, next); in btshell_chr_delete()
386 while ((chr = SLIST_FIRST(&svc->chrs)) != NULL) { in btshell_svc_delete()
387 SLIST_REMOVE_HEAD(&svc->chrs, next); in btshell_svc_delete()
409 svc = btshell_svc_find(conn, gatt_svc->start_handle, &prev); in btshell_svc_add()
422 svc->svc = *gatt_svc; in btshell_svc_add()
423 SLIST_INIT(&svc->chrs); in btshell_svc_add()
426 SLIST_INSERT_HEAD(&conn->svcs, svc, next); in btshell_svc_add()
441 SLIST_FOREACH(chr, &svc->chrs, next) { in btshell_chr_find_prev()
442 if (chr->chr.val_handle >= chr_val_handle) { in btshell_chr_find_prev()
461 chr = SLIST_FIRST(&svc->chrs); in btshell_chr_find()
466 if (chr != NULL && chr->chr.val_handle != chr_val_handle) { in btshell_chr_find()
500 chr = btshell_chr_find(svc, gatt_chr->val_handle, &prev); in btshell_chr_add()
513 chr->chr = *gatt_chr; in btshell_chr_add()
516 SLIST_INSERT_HEAD(&svc->chrs, chr, next); in btshell_chr_add()
531 SLIST_FOREACH(dsc, &chr->dscs, next) { in btshell_dsc_find_prev()
532 if (dsc->dsc.handle >= dsc_handle) { in btshell_dsc_find_prev()
551 dsc = SLIST_FIRST(&chr->dscs); in btshell_dsc_find()
556 if (dsc != NULL && dsc->dsc.handle != dsc_handle) { in btshell_dsc_find()
599 dsc = btshell_dsc_find(chr, gatt_dsc->handle, &prev); in btshell_dsc_add()
612 dsc->dsc = *gatt_dsc; in btshell_dsc_add()
615 SLIST_INSERT_HEAD(&chr->dscs, dsc, next); in btshell_dsc_add()
633 conn->handle = desc->conn_handle; in btshell_conn_add()
634 SLIST_INIT(&conn->svcs); in btshell_conn_add()
635 SLIST_INIT(&conn->coc_list); in btshell_conn_add()
649 while ((svc = SLIST_FIRST(&conn->svcs)) != NULL) { in btshell_conn_delete_idx()
650 SLIST_REMOVE_HEAD(&conn->svcs, next); in btshell_conn_delete_idx()
660 btshell_conns[i - 1] = btshell_conns[i]; in btshell_conn_delete_idx()
664 btshell_num_conns--; in btshell_conn_delete_idx()
671 switch (error->status) { in btshell_on_mtu()
708 SLIST_FOREACH(svc, &conn->svcs, next) { in btshell_disc_full_dscs()
709 SLIST_FOREACH(chr, &svc->chrs, next) { in btshell_disc_full_dscs()
711 SLIST_EMPTY(&chr->dscs) && in btshell_disc_full_dscs()
712 btshell_full_disc_prev_chr_val <= chr->chr.def_handle) { in btshell_disc_full_dscs()
715 chr->chr.val_handle, in btshell_disc_full_dscs()
721 btshell_full_disc_prev_chr_val = chr->chr.val_handle; in btshell_disc_full_dscs()
746 SLIST_FOREACH(svc, &conn->svcs, next) { in btshell_disc_full_chrs()
747 if (!svc_is_empty(svc) && SLIST_EMPTY(&svc->chrs)) { in btshell_disc_full_chrs()
748 rc = btshell_disc_all_chrs(conn_handle, svc->svc.start_handle, in btshell_disc_full_chrs()
749 svc->svc.end_handle); in btshell_disc_full_chrs()
765 switch (error->status) { in btshell_on_disc_s()
793 switch (error->status) { in btshell_on_disc_c()
818 switch (error->status) { in btshell_on_disc_d()
842 switch (error->status) { in btshell_on_read()
846 attr->handle, OS_MBUF_PKTLEN(attr->om)); in btshell_on_read()
847 print_mbuf(attr->om); in btshell_on_read()
867 switch (error->status) { in btshell_on_write()
870 "attr_handle=%d\n", conn_handle, attr->handle); in btshell_on_write()
889 switch (error->status) { in btshell_on_write_reliable()
919 adv_data_len = min(adv_data_len, scan_opts->limit); in btshell_decode_adv_data()
936 if (desc->props & BLE_HCI_ADV_LEGACY_MASK) { in btshell_decode_event_type()
937 if (scan_opts && scan_opts->ignore_legacy) { in btshell_decode_event_type()
941 console_printf("Legacy PDU type %d", desc->legacy_event_type); in btshell_decode_event_type()
942 if (desc->legacy_event_type == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND) { in btshell_decode_event_type()
949 if (desc->props & BLE_HCI_ADV_CONN_MASK) { in btshell_decode_event_type()
952 if (desc->props & BLE_HCI_ADV_SCAN_MASK) { in btshell_decode_event_type()
955 if (desc->props & BLE_HCI_ADV_DIRECT_MASK) { in btshell_decode_event_type()
960 if (desc->props & BLE_HCI_ADV_SCAN_RSP_MASK) { in btshell_decode_event_type()
964 switch(desc->data_status) { in btshell_decode_event_type()
975 console_printf("reserved %d", desc->data_status); in btshell_decode_event_type()
982 desc->rssi, desc->tx_power, desc->prim_phy, desc->sec_phy, in btshell_decode_event_type()
983 desc->sid, desc->addr.type); in btshell_decode_event_type()
984 print_addr(desc->addr.val); in btshell_decode_event_type()
986 console_printf(" init_addr_type=%d inita=", desc->direct_addr.type); in btshell_decode_event_type()
987 print_addr(desc->direct_addr.val); in btshell_decode_event_type()
992 if(!desc->length_data) { in btshell_decode_event_type()
996 btshell_decode_adv_data(desc->data, desc->length_data, arg); in btshell_decode_event_type()
1011 if (event->type != BLE_GAP_EVENT_DISCONNECT) { in btshell_restart_adv()
1012 return -1; in btshell_restart_adv()
1019 event->disconnect.conn.conn_handle)) { in btshell_restart_adv()
1044 switch (event->type) { in btshell_gap_event()
1047 event->connect.status == 0 ? "established" : "failed", in btshell_gap_event()
1048 event->connect.status); in btshell_gap_event()
1050 if (event->connect.status == 0) { in btshell_gap_event()
1051 rc = ble_gap_conn_find(event->connect.conn_handle, &desc); in btshell_gap_event()
1059 console_printf("disconnect; reason=%d ", event->disconnect.reason); in btshell_gap_event()
1060 print_conn_desc(&event->disconnect.conn); in btshell_gap_event()
1062 conn_idx = btshell_conn_find_idx(event->disconnect.conn.conn_handle); in btshell_gap_event()
1063 if (conn_idx != -1) { in btshell_gap_event()
1070 btshell_decode_event_type(&event->ext_disc, arg); in btshell_gap_event()
1075 "addr_type=%d addr=", event->disc.event_type, in btshell_gap_event()
1076 event->disc.rssi, event->disc.addr.type); in btshell_gap_event()
1077 print_addr(event->disc.addr.val); in btshell_gap_event()
1083 if (event->disc.event_type == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND) { in btshell_gap_event()
1088 btshell_decode_adv_data(event->disc.data, event->disc.length_data, arg); in btshell_gap_event()
1094 event->conn_update.status); in btshell_gap_event()
1095 rc = ble_gap_conn_find(event->conn_update.conn_handle, &desc); in btshell_gap_event()
1102 *event->conn_update_req.self_params = in btshell_gap_event()
1103 *event->conn_update_req.peer_params; in btshell_gap_event()
1108 event->passkey.params.action); in btshell_gap_event()
1109 if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) { in btshell_gap_event()
1111 (unsigned long)event->passkey.params.numcmp); in btshell_gap_event()
1119 event->disc_complete.reason); in btshell_gap_event()
1125 event->adv_complete.reason, event->adv_complete.instance, in btshell_gap_event()
1126 event->adv_complete.conn_handle); in btshell_gap_event()
1128 ext_adv_restart[event->adv_complete.instance].conn_handle = in btshell_gap_event()
1129 event->adv_complete.conn_handle; in btshell_gap_event()
1132 event->adv_complete.reason); in btshell_gap_event()
1138 event->enc_change.status); in btshell_gap_event()
1139 rc = ble_gap_conn_find(event->enc_change.conn_handle, &desc); in btshell_gap_event()
1147 event->notify_rx.attr_handle, in btshell_gap_event()
1148 event->notify_rx.indication, in btshell_gap_event()
1149 OS_MBUF_PKTLEN(event->notify_rx.om)); in btshell_gap_event()
1151 print_mbuf(event->notify_rx.om); in btshell_gap_event()
1158 event->notify_tx.status, in btshell_gap_event()
1159 event->notify_tx.attr_handle, in btshell_gap_event()
1160 event->notify_tx.indication); in btshell_gap_event()
1166 event->subscribe.conn_handle, in btshell_gap_event()
1167 event->subscribe.attr_handle, in btshell_gap_event()
1168 event->subscribe.reason, in btshell_gap_event()
1169 event->subscribe.prev_notify, in btshell_gap_event()
1170 event->subscribe.cur_notify, in btshell_gap_event()
1171 event->subscribe.prev_indicate, in btshell_gap_event()
1172 event->subscribe.cur_indicate); in btshell_gap_event()
1177 event->mtu.conn_handle, in btshell_gap_event()
1178 event->mtu.channel_id, in btshell_gap_event()
1179 event->mtu.value); in btshell_gap_event()
1184 rc = ble_gap_conn_find(event->identity_resolved.conn_handle, &desc); in btshell_gap_event()
1192 event->phy_updated.status, in btshell_gap_event()
1193 event->phy_updated.conn_handle, in btshell_gap_event()
1194 event->phy_updated.tx_phy, in btshell_gap_event()
1195 event->phy_updated.rx_phy); in btshell_gap_event()
1205 rc = ble_gap_conn_find(event->repeat_pairing.conn_handle, &desc); in btshell_gap_event()
1209 /* Return BLE_GAP_REPEAT_PAIRING_RETRY to indicate that the host should in btshell_gap_event()
1248 om->om_len = len + 4; in btshell_tx_timer_cb()
1249 put_le16(om->om_data, btshell_tx_data.tx_handle); in btshell_tx_timer_cb()
1250 put_le16(om->om_data + 2, len); in btshell_tx_timer_cb()
1251 dptr = om->om_data + 4; in btshell_tx_timer_cb()
1258 put_le16(dptr, len - 4); in btshell_tx_timer_cb()
1262 len -= 4; in btshell_tx_timer_cb()
1270 OS_MBUF_PKTHDR(om)->omp_len = om->om_len; in btshell_tx_timer_cb()
1273 --btshell_tx_data.tx_num; in btshell_tx_timer_cb()
1361 while ((svc = SLIST_FIRST(&conn->svcs)) != NULL) { in btshell_disc_full()
1362 SLIST_REMOVE_HEAD(&conn->svcs, next); in btshell_disc_full()
1585 console_printf(" Configure nimble host to enable it\n"); in btshell_ext_conn_initiate()
1659 console_printf(" Configure nimble host to enable it\n"); in btshell_ext_scan()
1825 return -1; in btshell_tx_start()
1830 return -2; in btshell_tx_start()
1865 console_printf("Host and controller synced\n"); in btshell_on_sync()
1885 coc->chan = chan; in btshell_l2cap_coc_add()
1888 SLIST_FOREACH(cur, &conn->coc_list, next) { in btshell_l2cap_coc_add()
1893 SLIST_INSERT_HEAD(&conn->coc_list, coc, next); in btshell_l2cap_coc_add()
1912 SLIST_FOREACH(cur, &conn->coc_list, next) { in btshell_l2cap_coc_remove()
1913 if (cur->chan == chan) { in btshell_l2cap_coc_remove()
1923 SLIST_REMOVE(&conn->coc_list, coc, btshell_l2cap_coc, next); in btshell_l2cap_coc_remove()
1964 switch(event->type) { in btshell_l2cap_event()
1966 if (event->connect.status) { in btshell_l2cap_event()
1967 console_printf("LE COC error: %d\n", event->connect.status); in btshell_l2cap_event()
1973 event->connect.conn_handle, in btshell_l2cap_event()
1974 (uint32_t) event->connect.chan, in btshell_l2cap_event()
1975 ble_l2cap_get_scid(event->connect.chan), in btshell_l2cap_event()
1976 ble_l2cap_get_dcid(event->connect.chan), in btshell_l2cap_event()
1977 ble_l2cap_get_our_mtu(event->connect.chan), in btshell_l2cap_event()
1978 ble_l2cap_get_peer_mtu(event->connect.chan)); in btshell_l2cap_event()
1980 btshell_l2cap_coc_add(event->connect.conn_handle, in btshell_l2cap_event()
1981 event->connect.chan); in btshell_l2cap_event()
1986 (uint32_t) event->disconnect.chan); in btshell_l2cap_event()
1988 btshell_l2cap_coc_remove(event->disconnect.conn_handle, in btshell_l2cap_event()
1989 event->disconnect.chan); in btshell_l2cap_event()
1997 return btshell_l2cap_coc_accept(event->accept.conn_handle, in btshell_l2cap_event()
1998 event->accept.peer_sdu_size, in btshell_l2cap_event()
1999 event->accept.chan); in btshell_l2cap_event()
2002 btshell_l2cap_coc_recv(event->receive.chan, event->receive.sdu_rx); in btshell_l2cap_event()
2015 console_printf(" Configure nimble host to enable it\n"); in btshell_l2cap_create_srv()
2029 console_printf(" Configure nimble host to enable it\n"); in btshell_l2cap_connect()
2048 console_printf(" Configure nimble host to enable it\n"); in btshell_l2cap_disconnect()
2061 SLIST_FOREACH(coc, &conn->coc_list, next) { in btshell_l2cap_disconnect()
2069 rc = ble_l2cap_disconnect(coc->chan); in btshell_l2cap_disconnect()
2083 console_printf(" Configure nimble host to enable it\n"); in btshell_l2cap_send()
2103 SLIST_FOREACH(coc, &conn->coc_list, next) { in btshell_l2cap_send()
2121 * to validate on other side. In this loop we add as many full chunks as we in btshell_l2cap_send()
2134 rc = os_mbuf_append(sdu_tx, b, bytes - (sizeof(b) * i)); in btshell_l2cap_send()
2141 rc = ble_l2cap_send(coc->chan, sdu_tx); in btshell_l2cap_send()
2212 /* Initialize the NimBLE host configuration. */ in btshell_init()
2224 rc = ble_svc_gap_device_name_set("nimble-btshell"); in btshell_init()
2235 /* startup bluetooth host stack*/ in btshell_init()
2242 * Bluetooth shell porting on RT-Thread
2305 btshell_console.old_rx_ind = uart_console->rx_indicate; in rt_btshell_init()
2325 return -RT_ERROR; in rt_btshell_init()
2379 cur_line[--cur_line_len] = 0; in rt_btshell_parser()