110 #if (HARDWARE != SIMULATION)
118 #include <sys/mman.h>
122 #include <bluetooth/bluetooth.h>
123 #include <bluetooth/rfcomm.h>
124 #include <bluetooth/hci.h>
125 #include <bluetooth/hci_lib.h>
126 #include <bluetooth/sdp.h>
127 #include <bluetooth/sdp_lib.h>
128 #include <sys/socket.h>
130 #include <dbus/dbus.h>
132 #include <sys/poll.h>
133 #include <sys/ioctl.h>
143 static PAIREDDEVINFO PairedDevInfo;
146 static DBusConnection *conn;
147 static DBusMessage *reply;
148 static DBusMessage *RejectReply;
150 static sdp_session_t *session = 0;
152 static char *adapter_path =
NULL;
153 char *agent_path =
"/org/bluez/agent";
154 static UBYTE SimplePairingDisable[] = {0x06, 0x73, 0xFF};
155 static UBYTE SimplePairingEnable[] = {0x06, 0x7B, 0xFF};
156 static UBYTE ExtendedFeaturesDisable[] = {0x07, 0x03, 0xFF};
157 static UBYTE ExtendedFeaturesEnable[] = {0x07, 0x83, 0xFF};
159 static volatile sig_atomic_t __io_canceled = 0;
160 static volatile sig_atomic_t __io_terminated = 0;
168 gBtInstance= _Instance;
179 #define LEGO_BUNDLE_SEED_ID "9RNK8ZF528"
180 #define LEGO_BUNDLE_ID "com.lego.lms"
228 static char *get_adapter_path(DBusConnection *conn,
const char *adapter);
229 static DBusHandlerResult agent_message(DBusConnection *conn, DBusMessage *msg,
void *data);
230 static int register_agent(DBusConnection *conn,
const char *adapter_path,
const char *agent_path,
const char *capabilities);
231 static DBusHandlerResult agent_filter(DBusConnection *conn, DBusMessage *msg,
void *data);
232 static DBusHandlerResult request_pincode_message(DBusConnection *conn, DBusMessage *msg,
void *data);
233 static char *get_default_adapter_path(DBusConnection *conn);
234 static void sig_term(
int sig);
235 static int unregister_agent(DBusConnection *conn,
const char *adapter_path,
const char *agent_path);
237 static int RemoveDevice(DBusConnection *conn,
char *Device);
252 dev_id = hci_get_route(
NULL);
256 perror(
"Can't open socket");
263 struct hci_filter flt;
265 hci_filter_clear(&flt);
266 hci_filter_set_ptype(HCI_EVENT_PKT, &flt);
267 hci_filter_set_event(EVT_CONN_COMPLETE, &flt);
268 hci_filter_set_event(EVT_DISCONN_COMPLETE, &flt);
269 hci_filter_set_event(EVT_LINK_KEY_NOTIFY, &flt);
270 hci_filter_set_event(EVT_ENCRYPT_CHANGE, &flt);
271 hci_filter_set_event(EVT_CMD_COMPLETE, &flt);
272 hci_filter_set_event(EVT_CMD_STATUS, &flt);
274 hci_filter_set_event(EVT_INQUIRY_RESULT, &flt);
275 hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &flt);
276 hci_filter_set_event(EVT_INQUIRY_COMPLETE, &flt);
277 hci_filter_set_event(EVT_REMOTE_NAME_REQ_COMPLETE, &flt);
278 hci_filter_set_event(EVT_PIN_CODE_REQ, &flt);
280 hci_filter_set_event(EVT_CONN_REQUEST, &flt);
281 hci_filter_set_event(EVT_LINK_KEY_NOTIFY, &flt);
283 if (setsockopt(BtInstance.
HciSocket.
Socket, SOL_HCI, HCI_FILTER, &flt,
sizeof(flt)) < 0)
285 perror(
"Can't set HCI filter");
289 BtInstance.
HciSocket.
p.events = POLLIN | POLLERR | POLLHUP;
298 struct bt_security sec;
300 memset(&sec, 0,
sizeof(sec));
307 RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT,
308 RFCOMM_LM_AUTH | RFCOMM_LM_ENCRYPT | RFCOMM_LM_SECURE,
309 }, opt = lm_map[sec.level];
311 *Socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
317 setsockopt(*Socket, SOL_BLUETOOTH, BT_SECURITY, &sec,
sizeof(sec));
318 setsockopt(*Socket, SOL_RFCOMM, RFCOMM_LM, &opt,
sizeof(opt));
320 TmpSockFlags = fcntl(*Socket, F_GETFL, 0);
321 fcntl(*Socket, F_SETFL, TmpSockFlags | O_NONBLOCK);
359 FSer = fopen(
"./settings/BTser",
"r");
362 fgets((
char*)&(BtInstance.
Adr[0]), (
int)13, FSer);
368 strcpy((
char*)&(BtInstance.
Adr[0]),
"000000000000");
372 if (File >= MIN_HANDLE)
419 snprintf((
char*)&(BtInstance.
BtName[0]), vmBRICKNAMESIZE,
"%s",(
char*)pName);
433 if (File >= MIN_HANDLE)
445 if (MIN_HANDLE <= *pBtSocket)
514 BtInstance.
State = State;
559 write_inquiry_mode_cp cmp;
566 if (hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_HOST_CTL, OCF_WRITE_INQUIRY_MODE, WRITE_INQUIRY_MODE_RP_SIZE, &cmp) < 0)
569 printf(
"Can't set inquiry mode");
576 memset (&cp, 0,
sizeof(cp));
584 printf(
"Starting inquiry with RSSI...\n");
587 if (hci_send_cmd (BtInstance.
HciSocket.
Socket, OGF_LINK_CTL, OCF_INQUIRY, INQUIRY_CP_SIZE, &cp) < 0)
590 printf(
"Can't start inquiry");
632 remote_name_req_cp cp;
636 memset(&cp, 0,
sizeof(cp));
638 cp.pscan_rep_mode = 0x02;
640 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_LINK_CTL, OCF_REMOTE_NAME_REQ, REMOTE_NAME_REQ_CP_SIZE, &cp);
716 printf(
"\r\n MSG_BUF_FULL - Reading from cCom on Bt Channel 0 number of bytes = %d\r\n",pMsgBuf->
InPtr);
719 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
720 RtnLen = pMsgBuf->
InPtr;
738 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1 %d bytes copied\r\n",pMsgBuf->
InPtr);
741 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
742 RtnLen = pMsgBuf->
InPtr;
760 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
763 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
764 RtnLen = pMsgBuf->
InPtr;
782 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
785 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
786 RtnLen = pMsgBuf->
InPtr;
804 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
807 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
808 RtnLen = pMsgBuf->
InPtr;
826 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
829 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
830 RtnLen = pMsgBuf->
InPtr;
848 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
851 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
852 RtnLen = pMsgBuf->
InPtr;
869 printf(
"\r\n MSG_BUF_FULL on Bt Channel 1\r\n");
872 memcpy(pBuf, pMsgBuf->
Buf, (pMsgBuf->
InPtr));
873 RtnLen = pMsgBuf->
InPtr;
906 if (BytesAccepted == AvailBytes)
938 printf(
"\r\nDecode mode 1: Avail bytes = %d MsgBuf status = %d\r\n",AvailBytes,pMsgBuf->
Status);
961 pMsgBuf->
RemMsgLen = (int)(pMsgBuf->
Buf[0]) + ((int)(pMsgBuf->
Buf[1]) * 256);
978 printf(
" Message is received from MSG_BUF_EMPTY: ");
979 for (Test = 0; Test < ((pMsgBuf->
MsgLen) + 2); Test++)
981 printf(
"%02X ", pMsgBuf->
Buf[Test]);
998 memcpy(&(pMsgBuf->
Buf[pMsgBuf->
InPtr]), &(pReadBuf->
Buf[pReadBuf->
OutPtr]), AvailBytes);
1002 pMsgBuf->
InPtr += AvailBytes;
1005 pReadBuf->
InPtr = 0;
1011 if (0 == AvailBytes)
1015 pReadBuf->
InPtr = 0;
1031 pReadBuf->
InPtr = 0;
1046 pMsgBuf->
RemMsgLen = (int)(pMsgBuf->
Buf[0]) + ((int)(pMsgBuf->
Buf[1]) * 256);
1063 printf(
" Message is received from MSG_BUF_EMPTY: ");
1064 for (Test = 0; Test < ((pMsgBuf->
MsgLen) + 2); Test++)
1066 printf(
"%02X ", pMsgBuf->
Buf[Test]);
1071 if (0 == AvailBytes)
1075 pReadBuf->
InPtr = 0;
1083 memcpy(&(pMsgBuf->
Buf[pMsgBuf->
InPtr]), &(pReadBuf->
Buf[pReadBuf->
OutPtr]), AvailBytes);
1087 pMsgBuf->
InPtr += AvailBytes;
1090 pReadBuf->
InPtr = 0;
1096 if (0 == AvailBytes)
1100 pReadBuf->
InPtr = 0;
1113 BufFree = (
sizeof(pMsgBuf->
Buf) - (pMsgBuf->
InPtr));
1120 if (BufFree >= AvailBytes)
1123 memcpy(&(pMsgBuf->
Buf[pMsgBuf->
InPtr]), &(pReadBuf->
Buf[pReadBuf->
OutPtr]), AvailBytes);
1128 pMsgBuf->
InPtr += AvailBytes;
1132 pReadBuf->
InPtr = 0;
1138 memcpy(&(pMsgBuf->
Buf[pMsgBuf->
InPtr]), &(pReadBuf->
Buf[pReadBuf->
OutPtr]), BufFree);
1139 pReadBuf->
OutPtr += BufFree;
1140 pMsgBuf->
InPtr += BufFree;
1160 printf(
" Message is received from MSG_BUF_EMPTY: ");
1161 for (Test = 0; Test < ((pMsgBuf->
MsgLen) + 2); Test++)
1163 printf(
"%02X ", pMsgBuf->
Buf[Test]);
1168 if (0 == AvailBytes)
1172 pReadBuf->
InPtr = 0;
1180 memcpy(&(pMsgBuf->
Buf[pMsgBuf->
InPtr]), &(pReadBuf->
Buf[pReadBuf->
OutPtr]), AvailBytes);
1184 pMsgBuf->
InPtr += AvailBytes;
1187 pReadBuf->
InPtr = 0;
1214 struct timespec TimerData;
1217 memset(&(BtInstance.
BtCh), 0,
sizeof(BtInstance.
BtCh));
1241 clock_gettime(CLOCK_MONOTONIC,&TimerData);
1250 struct timespec TimerData;
1255 clock_gettime(CLOCK_MONOTONIC,&TimerData);
1256 Time = (
ULONG)TimerData.tv_nsec;
1257 if (400000000 < (Time - BtInstance.
Delay))
1271 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_VENDOR_CMD, 0xFF26, 0x03, &SimplePairingEnable);
1275 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_VENDOR_CMD, 0xFF26, 0x03, &SimplePairingDisable);
1289 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_VENDOR_CMD, 0xFF26, 0x03, &ExtendedFeaturesEnable);
1293 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_VENDOR_CMD, 0xFF26, 0x03, &ExtendedFeaturesDisable);
1309 Auth = AUTH_DISABLED;
1313 Auth = AUTH_ENABLED;
1316 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE, 1, &Auth);
1325 struct timespec TimerData;
1333 clock_gettime(CLOCK_MONOTONIC,&TimerData);
1343 struct timespec TimerData;
1348 clock_gettime(CLOCK_MONOTONIC,&TimerData);
1349 Time = (
ULONG)TimerData.tv_nsec;
1350 if (400000000 < (Time - BtInstance.
Delay))
1367 change_local_name_cp cp;
1369 snprintf((
char *)&(cp.name[0]), vmBRICKNAMESIZE,
"%s", (
char *)BtInstance.
BtName);
1370 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME, CHANGE_LOCAL_NAME_CP_SIZE, &cp);
1385 uint32_t svc_uuid_int[] = { 0, 0xDEFACADE, 0xAFDECADE, 0xFFCACADE };
1386 uint8_t rfcomm_channel = 1;
1387 const char *service_name =
"Wireless EV3";
1388 const char *service_dsc =
"MINDSTORMS EV3";
1389 const char *service_prov =
"LEGO";
1393 uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid;
1394 sdp_list_t *l2cap_list = 0,
1398 *access_proto_list = 0,
1399 *svc_class_list = 0,
1401 sdp_data_t *channel = 0;
1402 sdp_profile_desc_t profile;
1405 sdp_record_t *record = sdp_record_alloc();
1408 sdp_uuid128_create( &svc_uuid, &svc_uuid_int );
1410 pUUID = &(svc_uuid.value.uuid128.data[0]);
1412 sdp_set_service_id( record, svc_uuid );
1414 pUUID = &(record->svclass.value.uuid128.data[0]);
1417 svc_class_list = sdp_list_append(0, &svc_uuid);
1418 sdp_set_service_classes(record, svc_class_list);
1420 pUUID = &(record->svclass.value.uuid128.data[0]);
1423 sdp_uuid16_create(&profile.uuid, SERIAL_PORT_PROFILE_ID);
1424 profile.version = 0x0100;
1425 profile_list = sdp_list_append(0, &profile);
1426 sdp_set_profile_descs(record, profile_list);
1429 sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
1430 root_list = sdp_list_append(0, &root_uuid);
1431 sdp_set_browse_groups( record, root_list );
1434 sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
1435 l2cap_list = sdp_list_append( 0, &l2cap_uuid );
1436 proto_list = sdp_list_append( 0, l2cap_list );
1439 sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
1440 channel = sdp_data_alloc(SDP_UINT8, &rfcomm_channel);
1441 rfcomm_list = sdp_list_append( 0, &rfcomm_uuid );
1442 sdp_list_append( rfcomm_list, channel );
1443 sdp_list_append( proto_list, rfcomm_list );
1444 access_proto_list = sdp_list_append( 0, proto_list );
1445 sdp_set_access_protos( record, access_proto_list );
1448 sdp_set_info_attr(record, service_name, service_prov, service_dsc);
1450 session = sdp_connect( BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY );
1452 pUUID = &(record->svclass.value.uuid128.data[0]);
1454 err = sdp_record_register(session, record, 0);
1457 sdp_data_free( channel );
1458 sdp_list_free( l2cap_list, 0 );
1459 sdp_list_free( rfcomm_list, 0 );
1460 sdp_list_free( root_list, 0 );
1461 sdp_list_free( access_proto_list, 0 );
1463 sdp_list_free( proto_list, 0 );
1464 sdp_list_free( svc_class_list, 0 );
1465 sdp_list_free( profile_list, 0 );
1477 char match_string[128], *adapter_id =
NULL;
1478 struct sigaction sa;
1480 static const DBusObjectPathVTable agent_table =
1482 .message_function = agent_message,
1484 const char *capabilities =
"DisplayYesNo";
1494 conn = dbus_bus_get(DBUS_BUS_SYSTEM,
NULL);
1495 adapter_path = get_adapter_path(conn, adapter_id);
1497 if (!dbus_connection_register_object_path(conn, agent_path, &agent_table,
NULL))
1499 fprintf(stderr,
"Can't register object path for agent\n");
1502 if (register_agent(conn, adapter_path, agent_path, capabilities) < 0)
1504 dbus_connection_unref(conn);
1508 if (!dbus_connection_add_filter(conn, agent_filter,
NULL,
NULL))
1509 fprintf(stderr,
"Can't add signal filter");
1511 snprintf(match_string,
sizeof(match_string),
1512 "interface=%s,member=NameOwnerChanged,arg0=%s",
1513 DBUS_INTERFACE_DBUS,
"org.bluez");
1515 dbus_bus_add_match(conn, match_string,
NULL);
1517 memset(&sa, 0,
sizeof(sa));
1518 sa.sa_flags = SA_NOCLDSTOP;
1519 sa.sa_handler = sig_term;
1520 sigaction(SIGTERM, &sa,
NULL);
1521 sigaction(SIGINT, &sa,
NULL);
1536 unregister_agent(conn, adapter_path, agent_path);
1575 switch(BtInstance.
State)
1583 dbus_connection_read_write_dispatch(conn, 0);
1590 if (0 <= pBtSocket->
Socket)
1601 printf(
"Remote connection accepted, address: %s \r\n",tmpbuf);
1643 if ((pBtSocket->
Socket != -1))
1648 pBtSocket->
Cmdtv.tv_sec = 0;
1649 pBtSocket->
Cmdtv.tv_usec = 0;
1650 FD_ZERO(&(pBtSocket->
Cmdfds));
1654 BytesRead = read(pBtSocket->
Socket, pReadBuf->
Buf,
sizeof(pReadBuf->
Buf));
1662 printf(
"\r\nData received on BT in Slave mode");
1666 pReadBuf->
InPtr = BytesRead;
1670 for (Cnt = 0; Cnt < BytesRead; Cnt++)
1672 printf(
"\r\n Rx byte nr %02d = %02X",Cnt,pReadBuf->
Buf[Cnt]);
1709 dbus_connection_read_write_dispatch(conn, 0);
1722 pBtSocket->
Cmdtv.tv_sec = 0;
1723 pBtSocket->
Cmdtv.tv_usec = 0;
1724 FD_ZERO(&(pBtSocket->
Cmdfds));
1732 if (0 < SocketReturn)
1752 BytesRead = read(pBtSocket->
Socket, pReadBuf->
Buf,
sizeof(pReadBuf->
Buf));
1758 pReadBuf->
InPtr = BytesRead;
1839 PAIREDDEVINFO *pPairedDevInfo;
1840 struct sockaddr_rc addr;
1841 int sock_flags, status;
1845 pPairedDevInfo = (PAIREDDEVINFO*)user_data;
1847 BtInstance.
BtCh[pPairedDevInfo->Port].
BtSocket.
Socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
1849 addr.rc_family = AF_BLUETOOTH;
1850 addr.rc_channel = 1;
1852 bacpy(&(addr.rc_bdaddr), &(pPairedDevInfo->Addr));
1854 sock_flags = fcntl(BtInstance.
BtCh[pPairedDevInfo->Port].
BtSocket.
Socket, F_GETFL, 0);
1855 fcntl(BtInstance.
BtCh[pPairedDevInfo->Port].
BtSocket.
Socket, F_SETFL, sock_flags | O_NONBLOCK);
1857 status = connect(BtInstance.
BtCh[pPairedDevInfo->Port].
BtSocket.
Socket,(
struct sockaddr *) &addr,
sizeof(addr));
1866 const char *agent_path,
1867 const char *capabilities,
1871 dbus_bool_t success;
1873 DBusPendingCall *pending;
1876 str2ba(device, &(PairedDevInfo.Addr));
1877 PairedDevInfo.Port = Port;
1879 msg = dbus_message_new_method_call(
"org.bluez", adapter_path,
"org.bluez.Adapter",
"CreatePairedDevice");
1882 fprintf(stderr,
"Can't allocate new method call\n");
1886 dbus_message_append_args(msg, DBUS_TYPE_STRING, &device, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_STRING, &capabilities, DBUS_TYPE_INVALID);
1888 success = dbus_connection_send_with_reply(conn, msg, &pending, -1);
1895 dbus_message_unref(msg);
1899 fprintf(stderr,
"Not enough memory for message send\n");
1903 dbus_connection_flush(conn);
1912 const char *capabilities =
"DisplayYesNo";
1918 snprintf(Agent,
sizeof(Agent),
"/org/bluez/agent_%d", getpid());
1920 ba2str((bdaddr_t *)(&(BtAddr)), Addr);
2061 Visibility |= SCAN_PAGE;
2066 Visibility |= SCAN_INQUIRY;
2069 Status = hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE, 1, &Visibility);
2158 memset(&(BtInstance.
SearchList[Index].
Adr.b[0]), 0,
sizeof(bdaddr_t));
2201 printf(
"Connecting from IDLE... \r\n");
2223 printf(
"Connecting from MASTER PortIndex = %d, Addr = %s \r\n",PortIndex,Addr);
2266 printf(
"Wrong Mode... = %d \r\n", (
int)BtInstance.
State);
2285 AllReadyConn =
FALSE;
2295 AllReadyConn =
TRUE;
2300 if (
FALSE == AllReadyConn)
2316 printf(
"\r\n ..... c_bt_connect....Name = %s\r\n",pDevName);
2323 printf(
"\r\nFound in dev table: index = %d, name = %s, Port no = %d\r\n", Index, pDevName, PortIndex);
2334 printf(
"\r\n ..... Found in search table index = %d.... name = %s\r\n", Index, pDevName);
2479 if (-1 != pBtSocket->
Socket)
2482 pBtSocket->
Cmdtv.tv_sec = 0;
2483 pBtSocket->
Cmdtv.tv_usec = 0;
2484 FD_ZERO(&(pBtSocket->
Cmdfds));
2489 if (0 < SocketReturn)
2492 NoWritten = send(pBtSocket->
Socket, &(pWriteBuf->
Buf[pWriteBuf->
OutPtr]), ByteCnt, (
int)0);
2496 pWriteBuf->
OutPtr += NoWritten;
2499 printf(
"\r\n.... transmitted to socket = %d on chno = %d, Bytes to send %d, Bytes written = %d \r\n",pBtSocket->
Socket, Cnt, ByteCnt, NoWritten);
2500 printf(
"\r\n errno = %d\r\n", errno);
2506 pWriteBuf->
InPtr = 0;
2515 pWriteBuf->
InPtr = 0;
2912 unsigned char buf[HCI_MAX_EVENT_SIZE];
2921 if (poll(&(BtInstance.
HciSocket.
p), 1, 0) > 0)
2928 hdr = (
void *) (buf + 1);
2929 ptr = buf + (1 + HCI_EVENT_HDR_SIZE);
2935 case EVT_PIN_CODE_REQ:
2938 if (0 == bacmp(&(BtInstance.
TrustedDev.
Adr), &((evt_pin_code_req*)ptr)->bdaddr))
2948 case EVT_CONN_REQUEST:
2954 remote_name_req_cp cp;
2957 printf(
"EVT_CONN_REQUEST from outside this is slave..... \r\n");
2961 bacpy(&(BtInstance.
Incoming.
Adr), &((evt_conn_request*)ptr)->bdaddr);
2962 memcpy(&(BtInstance.
Incoming.
DevClass[0]), &(((evt_conn_request*)ptr)->dev_class[0]), 3);
2966 memset(&cp, 0,
sizeof(cp));
2967 bacpy(&cp.bdaddr, &((evt_conn_request*)ptr)->bdaddr);
2968 cp.pscan_rep_mode = 0x02;
2969 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_LINK_CTL, OCF_REMOTE_NAME_REQ, REMOTE_NAME_REQ_CP_SIZE, &cp);
2974 case EVT_CONN_COMPLETE:
2979 if (0 != ((evt_conn_complete*)ptr)->status)
2983 if (OK ==
cBtFindDevAdr(&((evt_conn_complete*)ptr)->bdaddr, &DevIndex))
2992 printf(
"EVT_CONN_COMPLETE - FAIL !!!!! Status = %d \r\n",((evt_conn_complete*)ptr)->status);
3004 if (FAIL !=
cBtFindDevAdr(&((evt_conn_complete*)ptr)->bdaddr, &DevIndex))
3012 if (OK ==
cBtFindSearchAdr(&((evt_conn_complete*)ptr)->bdaddr, &SearchIndex))
3031 case EVT_INQUIRY_RESULT_WITH_RSSI:
3034 inquiry_info_with_rssi *info_rssi;
3038 for (i = 0; i < results; i++)
3040 info_rssi = (
void *)ptr + (
sizeof(*info_rssi) * i) + 1;
3052 if (0 == bacmp(&(BtInstance.
NonVol.
DevList[Tmp].
Adr), &(info_rssi->bdaddr)))
3066 if (
FALSE == DevStatus)
3077 case EVT_INQUIRY_COMPLETE:
3089 printf(
"inquiry done.... exiting \r\n");
3118 case EVT_REMOTE_NAME_REQ_COMPLETE:
3121 evt_remote_name_req_complete *rn;
3126 printf(
"EVT_REMOTE_NAME_REQ_COMPLETE\r\n");
3146 if (0 == bacmp(&(BtInstance.
NonVol.
DevList[Cnt].
Adr), (bdaddr_t*)&(rn->bdaddr)))
3150 printf(
"\r\nUpdated name in favourite list \r\n");
3170 printf(
"inquiry done.... exiting \r\n");
3205 if (0 == bacmp(&(BtInstance.
NonVol.
DevList[Cnt].
Adr), (bdaddr_t*)&(rn->bdaddr)))
3209 printf(
"\r\nUpdated name in favourite list \r\n");
3219 if (0 == bacmp(&(BtInstance.
Incoming.
Adr), (bdaddr_t*)&(rn->bdaddr)))
3223 printf(
"\r\nUpdated name in favourite list \r\n");
3232 case EVT_DISCONN_COMPLETE:
3237 if (0 == ((evt_disconn_complete*)ptr)->status)
3239 ConnHandle = ((evt_disconn_complete*)ptr)->handle;
3265 case EVT_LINK_KEY_NOTIFY:
3270 if ((0 == ((evt_link_key_notify*)ptr)->key_type) || (5 == ((evt_link_key_notify*)ptr)->key_type))
3278 printf(
"\r\nEVT_CONN_COMPLETE in master mode: DevIndex = %d, ChNo = %d\r\n",DevIndex, BtInstance.
OutGoing.
ChNo);
3283 if (OK ==
cBtFindSearchAdr(&((evt_link_key_notify*)ptr)->bdaddr, &SearchIndex))
3304 case EVT_CMD_COMPLETE:
3306 switch(((evt_cmd_complete*)ptr)->opcode)
3308 case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE):
3316 case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_CLASS_OF_DEV):
3323 case cmd_opcode_pack(OGF_HOST_CTL, OCF_DELETE_STORED_LINK_KEY):
3330 case cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY_CANCEL):
3339 case cmd_opcode_pack(OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME):
3346 case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE):
3352 case cmd_opcode_pack(OGF_INFO_PARAM, OCF_READ_BD_ADDR):
3360 case cmd_opcode_pack(OCF_WRITE_SIMPLE_PAIRING_MODE, WRITE_SIMPLE_PAIRING_MODE_CP_SIZE):
3366 case cmd_opcode_pack(OGF_HOST_CTL, OCF_READ_SIMPLE_PAIRING_MODE):
3372 case cmd_opcode_pack(OGF_HOST_CTL, OCF_RESET):
3378 case cmd_opcode_pack(OGF_HOST_CTL, OCF_SET_EVENT_MASK):
3384 case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_LE_HOST_SUPPORTED):
3390 case cmd_opcode_pack(OGF_HOST_CTL, OCF_READ_EXT_INQUIRY_RESPONSE):
3396 case cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_EXT_INQUIRY_RESPONSE):
3402 case cmd_opcode_pack(OGF_VENDOR_CMD, 0xFF26):
3416 case EVT_ENCRYPT_CHANGE:
3460 Type = BTTYPE_UNKNOWN;
3461 if ((0x08 == pCod[1]) && (0x04 == pCod[0]))
3463 Type = BTTYPE_BRICK;
3467 if (0x01 == pCod[1])
3473 if (0x02 == pCod[1])
3475 Type = BTTYPE_PHONE;
3500 if (ConnCnt == Item)
3578 RemoveDevice(conn, Addr);
3647 strncpy((
char*)pId, &(BtInstance.
Adr[0]), Length);
3654 change_local_name_cp cp;
3660 snprintf((
char *)&(BtInstance.
BtName[0]), Length,
"%s", (
char *)pName);
3662 snprintf((
char *)&(cp.name[0]), Length,
"%s", (
char *)pName);
3663 hci_send_cmd(BtInstance.
HciSocket.
Socket, OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME, CHANGE_LOCAL_NAME_CP_SIZE, &cp);
3674 snprintf((
char *)&(BtInstance.
BtName[0]), Length,
"%s", (
char *)pName);
3708 static char *get_adapter_path(DBusConnection *conn,
const char *adapter)
3710 DBusMessage *msg, *reply;
3712 const char *reply_path;
3716 return get_default_adapter_path(conn);
3718 msg = dbus_message_new_method_call(
"org.bluez",
"/",
3719 "org.bluez.Manager",
"FindAdapter");
3723 fprintf(stderr,
"Can't allocate new method call\n");
3727 dbus_message_append_args(msg, DBUS_TYPE_STRING, &adapter,
3730 dbus_error_init(&err);
3733 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
3735 dbus_message_unref(msg);
3739 fprintf(stderr,
"Can't find adapter %s\n", adapter);
3740 if (dbus_error_is_set(&err))
3742 fprintf(stderr,
"%s\n", err.message);
3743 dbus_error_free(&err);
3748 if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH, &reply_path, DBUS_TYPE_INVALID))
3750 fprintf(stderr,
"Can't get reply arguments\n");
3751 if (dbus_error_is_set(&err))
3753 fprintf(stderr,
"%s\n", err.message);
3754 dbus_error_free(&err);
3759 path = strdup(reply_path);
3761 dbus_message_unref(reply);
3763 dbus_connection_flush(conn);
3769 static DBusHandlerResult request_confirmation_message(DBusConnection *L_conn, DBusMessage *msg,
void *data)
3775 if (!dbus_message_get_args(msg,
NULL, DBUS_TYPE_OBJECT_PATH, &path,
3778 fprintf(stderr,
"Invalid arguments for RequestPasskey method");
3779 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3783 RejectReply = dbus_message_new_error(msg,
"org.bluez.Error.Rejected",
"");
3784 reply = dbus_message_new_method_return(msg);
3787 fprintf(stderr,
"Can't create reply message\n");
3788 return DBUS_HANDLER_RESULT_NEED_MEMORY;
3791 BtInstance.
Events = 0x02;
3793 return DBUS_HANDLER_RESULT_HANDLED;
3797 static DBusHandlerResult agent_message(DBusConnection *L_conn, DBusMessage *msg,
void *data)
3799 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"RequestPinCode"))
3802 return request_pincode_message(L_conn, msg, data);
3805 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"RequestPasskey"))
3810 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"RequestConfirmation"))
3813 return request_confirmation_message(L_conn, msg, data);
3816 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"Authorize"))
3821 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"Cancel"))
3826 if (dbus_message_is_method_call(msg,
"org.bluez.Agent",
"Release"))
3831 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3835 static int register_agent(DBusConnection *conn,
const char *adapter_path,
const char *agent_path,
const char *capabilities)
3837 DBusMessage *msg, *reply;
3843 msg = dbus_message_new_method_call(
"org.bluez", adapter_path,
"org.bluez.Adapter",
"RegisterAgent");
3847 fprintf(stderr,
"Can't allocate new method call\n");
3853 dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_STRING, &capabilities, DBUS_TYPE_INVALID);
3854 dbus_error_init(&err);
3857 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
3858 dbus_message_unref(msg);
3863 fprintf(stderr,
"Can't register agent\n");
3865 if (dbus_error_is_set(&err))
3867 fprintf(stderr,
"%s\n", err.message);
3868 dbus_error_free(&err);
3874 dbus_message_unref(reply);
3875 dbus_connection_flush(conn);
3882 static DBusHandlerResult agent_filter(DBusConnection *conn, DBusMessage *msg,
void *data)
3884 const char *name, *old, *
new;
3886 if (!dbus_message_is_signal(msg, DBUS_INTERFACE_DBUS,
"NameOwnerChanged"))
3888 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3891 if (!dbus_message_get_args(msg,
NULL,
3892 DBUS_TYPE_STRING, &name,
3893 DBUS_TYPE_STRING, &old,
3894 DBUS_TYPE_STRING, &
new,
3897 fprintf(stderr,
"Invalid arguments for NameOwnerChanged signal");
3898 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3901 if (!strcmp(name,
"org.bluez") && *
new ==
'\0')
3903 fprintf(stderr,
"Agent has been terminated\n");
3904 __io_terminated = 1;
3907 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3911 static DBusHandlerResult request_pincode_message(DBusConnection *conn, DBusMessage *msg,
void *data)
3914 DBusHandlerResult Result;
3917 if (!dbus_message_get_args(msg,
NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
3920 fprintf(stderr,
"Invalid arguments for RequestPinCode method");
3922 Result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
3926 reply = dbus_message_new_method_return(msg);
3930 fprintf(stderr,
"Can't create reply message\r\n");
3932 Result = DBUS_HANDLER_RESULT_NEED_MEMORY;
3944 dbus_message_append_args(reply, DBUS_TYPE_STRING, &pPin, DBUS_TYPE_INVALID);
3945 dbus_connection_send(conn, reply,
NULL);
3946 dbus_connection_flush(conn);
3947 dbus_message_unref(reply);
3954 Result = DBUS_HANDLER_RESULT_HANDLED;
3962 static char *get_default_adapter_path(DBusConnection *conn)
3964 DBusMessage *msg, *reply;
3966 const char *reply_path;
3969 msg = dbus_message_new_method_call(
"org.bluez",
"/",
"org.bluez.Manager",
"DefaultAdapter");
3973 fprintf(stderr,
"Can't allocate new method call\n");
3977 dbus_error_init(&err);
3979 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
3981 dbus_message_unref(msg);
3985 fprintf(stderr,
"Can't get default adapter\n");
3986 if (dbus_error_is_set(&err))
3988 fprintf(stderr,
"%s\n", err.message);
3989 dbus_error_free(&err);
3994 if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH, &reply_path, DBUS_TYPE_INVALID))
3996 fprintf(stderr,
"Can't get reply arguments\n");
3997 if (dbus_error_is_set(&err))
3999 fprintf(stderr,
"%s\n", err.message);
4000 dbus_error_free(&err);
4005 path = strdup(reply_path);
4007 dbus_message_unref(reply);
4009 dbus_connection_flush(conn);
4015 static int RemoveDevice(DBusConnection *conn,
char *Device)
4017 DBusMessage *msg, *reply;
4020 const char *reply_path;
4025 msg = dbus_message_new_method_call(
"org.bluez", adapter_path,
"org.bluez.Adapter",
"FindDevice");
4028 fprintf(stderr,
"Can't allocate new method call\n");
4034 dbus_message_append_args(msg, DBUS_TYPE_STRING, &Device, DBUS_TYPE_INVALID);
4035 dbus_error_init(&err);
4038 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
4039 dbus_message_unref(msg);
4044 fprintf(stderr,
"Can't register agent\r\n");
4046 if (dbus_error_is_set(&err))
4049 fprintf(stderr,
"%s \r\n", err.message);
4051 dbus_error_free(&err);
4058 if (!dbus_message_get_args(reply, &err, DBUS_TYPE_OBJECT_PATH, &reply_path, DBUS_TYPE_INVALID))
4061 fprintf(stderr,
"Can't get reply arguments\n");
4064 if (dbus_error_is_set(&err))
4067 fprintf(stderr,
"%s\n", err.message);
4070 dbus_error_free(&err);
4076 dbus_connection_flush(conn);
4078 Path = strdup(reply_path);
4079 dbus_message_unref(reply);
4081 msg = dbus_message_new_method_call(
"org.bluez", adapter_path,
"org.bluez.Adapter",
"RemoveDevice");
4085 fprintf(stderr,
"Can't allocate new method call\n");
4092 dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &Path, DBUS_TYPE_INVALID);
4093 dbus_error_init(&err);
4096 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
4097 dbus_message_unref(msg);
4102 fprintf(stderr,
"Can't register agent\n");
4104 if (dbus_error_is_set(&err))
4107 fprintf(stderr,
"%s\n", err.message);
4109 dbus_error_free(&err);
4115 dbus_message_unref(reply);
4116 dbus_connection_flush(conn);
4128 static void sig_term(
int sig)
4134 static int unregister_agent(DBusConnection *conn,
const char *adapter_path,
const char *agent_path)
4136 DBusMessage *msg, *reply;
4139 msg = dbus_message_new_method_call(
"org.bluez", adapter_path,
"org.bluez.Adapter",
"UnregisterAgent");
4143 fprintf(stderr,
"Can't allocate new method call\n");
4148 dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID);
4149 dbus_error_init(&err);
4150 reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
4151 dbus_message_unref(msg);
4156 fprintf(stderr,
"Can't unregister agent\n");
4158 if (dbus_error_is_set(&err))
4160 fprintf(stderr,
"%s\n", err.message);
4161 dbus_error_free(&err);
4166 dbus_message_unref(reply);
4167 dbus_connection_flush(conn);
4168 dbus_connection_unregister_object_path(conn, agent_path);
4199 dbus_message_append_args(reply, DBUS_TYPE_STRING, &pPin, DBUS_TYPE_INVALID);
4200 dbus_connection_send(conn, reply,
NULL);
4201 dbus_connection_flush(conn);
4202 dbus_message_unref(reply);
4222 dbus_connection_send(conn, reply,
NULL);
4223 dbus_connection_flush(conn);
4224 dbus_message_unref(reply);
4228 dbus_connection_send(conn, RejectReply,
NULL);
4229 dbus_connection_flush(conn);
4230 dbus_message_unref(RejectReply);
4253 sscanf((
char *)pBtStrAddr,
"%2X%2X%2X%2X%2X%2X", &(Ba[5]), &(Ba[4]), &(Ba[3]), &(Ba[2]), &(Ba[1]), &(Ba[0]));
4256 pAddr->b[5] = (uint8_t)Ba[5];
4257 pAddr->b[4] = (uint8_t)Ba[4];
4258 pAddr->b[3] = (uint8_t)Ba[3];
4259 pAddr->b[2] = (uint8_t)Ba[2];
4260 pAddr->b[1] = (uint8_t)Ba[1];
4261 pAddr->b[0] = (uint8_t)Ba[0];
void BtSetupPinEvent(void)
UWORD cBtSetBundleSeedId(UBYTE *pSeedId)
void cBtClearSearchConnectedStatus(UBYTE Index)
UWORD cBtReadCh2(UBYTE *pBuf, UWORD Length)
UBYTE cBtSetName(UBYTE *pName, UBYTE Length)
UBYTE cBtI2cBufReady(void)
struct sockaddr_rc loc_addr
UBYTE cBtGetChNo(UBYTE *pName, UBYTE *pChNos)
UBYTE BtConnectTo(UBYTE Port, bdaddr_t BtAddr)
UBYTE cBtConnect(UBYTE *pDevName)
UWORD cBtDevWriteBuf6(UBYTE *pBuf, UWORD Size)
void cBtSetDevConnectedStatus(UBYTE Index)
void BtSetup(UBYTE State)
cBtSetup
UBYTE cBtDisconnect(UBYTE *pName)
UBYTE BundleID[MAX_BUNDLE_ID_SIZE]
signed char SBYTE
Basic Type used to symbolise 8 bit signed values.
UBYTE cBtFindDevAdr(bdaddr_t *pAdr, UBYTE *pIndex)
UWORD cBtDevWriteBuf2(UBYTE *pBuf, UWORD Size)
UBYTE BtSetOnOff(UBYTE On)
UWORD cBtReadCh3(UBYTE *pBuf, UWORD Length)
UBYTE BtGetVisibility(void)
void DecodeMode1(UBYTE BufNo)
UBYTE cBtGetConnListEntry(UBYTE Item, UBYTE *pName, SBYTE Length, UBYTE *pType)
UBYTE BtSetMode2(UBYTE Mode2)
UBYTE cBtFindSearchAdr(bdaddr_t *pAdr, UBYTE *pIndex)
void create_paired_device_reply(DBusPendingCall *pending, void *user_data)
char Name[MAX_BT_NAME_SIZE]
UBYTE cBtFindDevName(UBYTE *pItem, UBYTE *pName, UBYTE StartIndex)
#define MAX_DEV_TABLE_ENTRIES
UWORD cBtReadCh5(UBYTE *pBuf, UWORD Length)
UWORD cBtDevWriteBuf7(UBYTE *pBuf, UWORD Size)
UBYTE cBtGetHciBusyFlag(void)
#define LEGO_BUNDLE_SEED_ID
UBYTE BtIssueHciVisible(UBYTE Visible, UBYTE Page)
UWORD cBtDevWriteBuf3(UBYTE *pBuf, UWORD Size)
void setOutputInstance(BT_GLOBALS *_Instance)
LISTENSOCKET ListenSocket
UBYTE BtGetOnOff(UBYTE *On)
UBYTE cBtGetDevListEntry(UBYTE Item, SBYTE *pConnected, SBYTE *pType, UBYTE *pName, SBYTE Length)
UBYTE cBtSetPin(UBYTE *pPin)
UBYTE cBtDiscChNo(UBYTE ChNo)
UWORD DataToMode2Decoding(UBYTE *pBuf, UWORD Length)
char BtName[vmBRICKNAMESIZE]
char Name[MAX_BT_NAME_SIZE]
UBYTE cBtFindDevChNo(UBYTE ChNo, UBYTE *pIndex)
void DecodeBtStream(UBYTE BufNo)
UBYTE cBtGetNoOfDevListEntries(void)
UBYTE Connect(bdaddr_t BdAddr, UBYTE PortNo)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
UWORD cBtReadCh0(UBYTE *pBuf, UWORD Length)
void BtCloseCh(UBYTE ChIndex)
void cBtSetTrustedDev(UBYTE *pBtAddr, UBYTE *pPin, UBYTE PinSize)
UBYTE BtClearSearchListEntry(UBYTE Index)
UWORD cBtSetBundleId(UBYTE *pId)
UWORD cBtReadCh6(UBYTE *pBuf, UWORD Length)
char Name[MAX_BT_NAME_SIZE]
UWORD cBtDevWriteBuf(UBYTE *pBuf, UWORD Size)
void BtSetupHciSocket(void)
UWORD BtRequestName(void)
UBYTE cBtDeleteFavourItem(UBYTE *pName)
#define MAX_BUNDLE_ID_SIZE
UWORD cBtReadCh4(UBYTE *pBuf, UWORD Length)
void BtDisconnectAll(void)
void BtCloseBtSocket(SLONG *pBtSocket)
UBYTE cBtGetSearchListEntry(UBYTE Item, SBYTE *pConnected, SBYTE *pType, SBYTE *pParred, UBYTE *pName, SBYTE Length)
void cBtGetId(UBYTE *pId, UBYTE Length)
UBYTE cBtGetNoOfConnListEntries(void)
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
UBYTE cBtDiscDevIndex(UBYTE Index)
UWORD cBtHandleHCI(void)
cBtHandleHCI
UWORD cBtReadCh1(UBYTE *pBuf, UWORD Length)
UWORD cBtI2cToBtBuf(UBYTE *pBuf, UWORD Size)
UBYTE cBtInsertInDeviceList(bdaddr_t *pBtAdr, UBYTE *pIndex)
void SetupListeningSocket(int *Socket)
DEVICELIST DevList[MAX_DEV_TABLE_ENTRIES]
UBYTE cBtGetNoOfSearchListEntries(void)
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
void cBtGetIncoming(UBYTE *pName, UBYTE *pCod, UBYTE Len)
UBYTE create_paired_device(DBusConnection *conn, const char *adapter_path, const char *agent_path, const char *capabilities, const char *device, UBYTE Port)
UBYTE cBtSetPasskey(UBYTE Accept)
signed short SWORD
Basic Type used to symbolise 16 bit signed values.
BT_GLOBALS * getBtInstance()
void cBtInsertDevConnHandle(UBYTE Index, UWORD ConnHandle)
SEARCHLIST SearchList[MAX_DEV_TABLE_ENTRIES]
RESULT I2cInit(READBUF *pBuf, WRITEBUF *pWriteBuf, char *pBundleId, char *pBundleSeedId)
UWORD cBtDevWriteBuf4(UBYTE *pBuf, UWORD Size)
void cBtCloseDevConnection(UBYTE Index)
UBYTE BundleSeedID[MAX_BUNDLE_SEED_ID_SIZE]
UBYTE cBtFindSearchName(UBYTE *pItem, UBYTE *pName)
UWORD cBtDevWriteBuf1(UBYTE *pBuf, UWORD Size)
UBYTE BtGetMode2(UBYTE *pMode2)
UBYTE BtSetVisibility(UBYTE State)
UBYTE cBtFindDevConnHandle(UBYTE ConnHandle, UBYTE *pIndex)
void BtClearChBuf(UBYTE ChNo)
void cBtSetSearchConnectedStatus(UBYTE Index)
struct sockaddr_rc rem_addr
void cBtStrNoColonToBa(UBYTE *pBtStrAddr, bdaddr_t *pAddr)
UBYTE cBtGetBtType(UBYTE *pCod)
signed int SLONG
Basic Type used to symbolise 32 bit signed values.
UWORD cBtDevWriteBuf5(UBYTE *pBuf, UWORD Size)
#define MAX_BUNDLE_SEED_ID_SIZE
UWORD cBtReadCh7(UBYTE *pBuf, UWORD Length)