diff --git a/Development/Software/Controller API/Bluetooth.cpp b/Development/Software/Controller API/Bluetooth.cpp index 404c86585c56e474ec24e4879fd113fc103ff6d1..e29f93d72c16486c9c95b6177b411bfba454bbd3 100644 --- a/Development/Software/Controller API/Bluetooth.cpp +++ b/Development/Software/Controller API/Bluetooth.cpp @@ -1,11 +1,11 @@ #include "Bluetooth.h" - -Bluetooth::Bluetooth() +namespace Bluetooth { -} + int myNum; - -Bluetooth::~Bluetooth() -{ + int scan() + { + return myNum; + } } diff --git a/Development/Software/Controller API/Bluetooth.h b/Development/Software/Controller API/Bluetooth.h index 54ff3bb8e6e34dd181c44b8621e55c5c71f1e55c..9e402b181854691ec0196a351a1022577ce21859 100644 --- a/Development/Software/Controller API/Bluetooth.h +++ b/Development/Software/Controller API/Bluetooth.h @@ -1,8 +1,8 @@ #pragma once namespace Bluetooth { - void Scan(); - + extern int myNum; + int Scan(); } diff --git a/Development/Software/Controller API/Client.cpp b/Development/Software/Controller API/Client.cpp index 175e77a8390355395f6144460e09fcccad6f17ab..2ef248d1a19821fc19cb3ab0b9b097b43e7728df 100644 --- a/Development/Software/Controller API/Client.cpp +++ b/Development/Software/Controller API/Client.cpp @@ -1,8 +1,11 @@ #include "Client.h" +struct sockaddr_rc Client::addr; +int Client::s, Client::status; + bool Client::cInit(string destination) { - if (destination.length() == 18) + if (destination.length() == 17) { // set the connection parameters (who to connect to) addr.rc_family = AF_BLUETOOTH; diff --git a/Development/Software/Controller API/Client.h b/Development/Software/Controller API/Client.h index 0d87a8a56a8433c7e56f42d89efc21633c17179a..3dacf30a705cebed500a92b82acaa94b57fea90b 100644 --- a/Development/Software/Controller API/Client.h +++ b/Development/Software/Controller API/Client.h @@ -12,8 +12,8 @@ using namespace std; namespace Client { - struct sockaddr_rc addr; - int s, status; + extern struct sockaddr_rc addr; + extern int s, status; bool cInit(string destination); diff --git a/Development/Software/Controller API/Controller API.vcxproj b/Development/Software/Controller API/Controller API.vcxproj index b6b74c30091b80a761d674ae30c5386729dd12fa..5c9f661f6f39651e40e40c671aeee91df1882a22 100644 --- a/Development/Software/Controller API/Controller API.vcxproj +++ b/Development/Software/Controller API/Controller API.vcxproj @@ -14,19 +14,18 @@ <ClCompile Include="Bluetooth.cpp" /> <ClCompile Include="Client.cpp" /> <ClCompile Include="Communications.cpp" /> + <ClCompile Include="Message.cpp" /> <ClCompile Include="Sensors.cpp" /> <ClCompile Include="Server.cpp" /> <ClCompile Include="Source.cpp" /> </ItemGroup> <ItemGroup> - <ClInclude Include="bluetoot.h" /> <ClInclude Include="Bluetooth.h" /> <ClInclude Include="Client.h" /> <ClInclude Include="Communications.h" /> - <ClInclude Include="rfcomm.h" /> + <ClInclude Include="Message.h" /> <ClInclude Include="Sensors.h" /> <ClInclude Include="Server.h" /> - <ClInclude Include="socket.h" /> </ItemGroup> <ItemGroup> <Text Include="Makefile.txt" /> diff --git a/Development/Software/Controller API/Controller API.vcxproj.filters b/Development/Software/Controller API/Controller API.vcxproj.filters index deec791ae6fe1bd6f60e433a1c782cf331036b9d..73930ba1e57c4bbc0f4c9d0e77d1296921cc908b 100644 --- a/Development/Software/Controller API/Controller API.vcxproj.filters +++ b/Development/Software/Controller API/Controller API.vcxproj.filters @@ -33,6 +33,9 @@ <ClCompile Include="Source.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="Message.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="Communications.h"> @@ -50,13 +53,7 @@ <ClInclude Include="Client.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="rfcomm.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="socket.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="bluetoot.h"> + <ClInclude Include="Message.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> diff --git a/Development/Software/Controller API/Message.cpp b/Development/Software/Controller API/Message.cpp new file mode 100644 index 0000000000000000000000000000000000000000..718b218a7d77224651f5cf6de5447b6bd00fe2e9 --- /dev/null +++ b/Development/Software/Controller API/Message.cpp @@ -0,0 +1,11 @@ +#include "Message.h" + + +Message::Message() +{ +} + + +Message::~Message() +{ +} diff --git a/Development/Software/Controller API/Message.h b/Development/Software/Controller API/Message.h new file mode 100644 index 0000000000000000000000000000000000000000..aba3b71fde979b1bf8152e9c086641d96be43e66 --- /dev/null +++ b/Development/Software/Controller API/Message.h @@ -0,0 +1,29 @@ +#pragma once + +#include <iostream> +#include <stdio.h> +#include <list> + +using namespace std; + +class<T> Message +{ +public: + Message(); + ~Message(); + + string getSender(); + string getDestination(); + + + ostream& operator>>(ostream& os); + + istream& operator<<(istream& is); +private: + string _sender; + string _destination; + + list<double> data; + +}; + diff --git a/Development/Software/Controller API/Server.cpp b/Development/Software/Controller API/Server.cpp index e0c5961298675bfaa411bb415a03be7893ec08fd..b961e298f88461f82f49985ae8ffab8b870605fb 100644 --- a/Development/Software/Controller API/Server.cpp +++ b/Development/Software/Controller API/Server.cpp @@ -1,5 +1,13 @@ #include "Server.h" +namespace Server +{ + struct sockaddr_rc loc_addr, rem_addr; + char buf[1024] = { 0 }; + int s, client, bytes_read; + socklen_t opt = sizeof rem_addr; +} + void Server::sInit() { // allocate socket @@ -28,6 +36,7 @@ string Server::sListen() string Server::sReadMessage() { + memset(buf, 0, sizeof(buf)); // read data from the client read(client, buf, sizeof(buf)); diff --git a/Development/Software/Controller API/Server.h b/Development/Software/Controller API/Server.h index 9c41b1f010fb0d46e13a7975e6d233048a5a5725..4ea1bc3c5e048171b43e275fa3021c7e6f88df1b 100644 --- a/Development/Software/Controller API/Server.h +++ b/Development/Software/Controller API/Server.h @@ -12,10 +12,10 @@ using namespace std; namespace Server { - struct sockaddr_rc loc_addr, rem_addr; - char buf[1024] = { 0 }; - int s, client, bytes_read; - socklen_t opt = sizeof rem_addr; + extern struct sockaddr_rc loc_addr; + extern char buf[1024]; + extern int s, client, bytes_read; + extern socklen_t opt; void sInit(); diff --git a/Development/Software/Controller API/Source.cpp b/Development/Software/Controller API/Source.cpp index 799525c8d78771e630dfa3c3a2e7e3dad7bc9edb..7831e81e07c01a4f61720e700470e91d2762b3ad 100644 --- a/Development/Software/Controller API/Source.cpp +++ b/Development/Software/Controller API/Source.cpp @@ -4,10 +4,11 @@ #include "Client.h" #include "Server.h" +#include "Capsule.h" using namespace std; -//using namespace Client; -//using namespace Server; +using namespace Client; +using namespace Server; void clientSide() { @@ -30,11 +31,13 @@ void clientSide() while (Client::cCheckStatus() && !stop) { - cin >> message; + getline(cin, message); - if (message.compare("STOP")) stop = true; + Capsule cap = Capsule(message); - Client::cSendMessage(message); + if (message.compare("STOP") == 0) stop = true; + + Client::cSendMessage((string)((char*)&cap)); } if (!Client::cCheckStatus()) @@ -63,8 +66,12 @@ void serverSide() while (!stop) { message = Server::sReadMessage(); - if (message.compare("STOP") == 0) stop = true; - else cout << message << endl; + + Capsule cap = (Capsule&)(*message.c_str()); + + + //if (message.compare("STOP") == 0) stop = true; + /*else*/ cout << cap.WhatDoIHave() << endl; } Server::sDisconnect(); diff --git a/Development/Software/Controller API/bluetoot.h b/Development/Software/Controller API/bluetoot.h deleted file mode 100644 index 61c1f9ac083426b3bdc2ff87ac66f100757811e0..0000000000000000000000000000000000000000 --- a/Development/Software/Controller API/bluetoot.h +++ /dev/null @@ -1,399 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2000-2001 Qualcomm Incorporated - * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> - * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __BLUETOOTH_H -#define __BLUETOOTH_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <stdint.h> -#include <string.h> -#include <endian.h> -#include <byteswap.h> -#include <netinet/in.h> - -#ifndef AF_BLUETOOTH -#define AF_BLUETOOTH 31 -#define PF_BLUETOOTH AF_BLUETOOTH -#endif - -#define BTPROTO_L2CAP 0 -#define BTPROTO_HCI 1 -#define BTPROTO_SCO 2 -#define BTPROTO_RFCOMM 3 -#define BTPROTO_BNEP 4 -#define BTPROTO_CMTP 5 -#define BTPROTO_HIDP 6 -#define BTPROTO_AVDTP 7 - -#define SOL_HCI 0 -#define SOL_L2CAP 6 -#define SOL_SCO 17 -#define SOL_RFCOMM 18 - -#ifndef SOL_BLUETOOTH -#define SOL_BLUETOOTH 274 -#endif - -#define BT_SECURITY 4 -struct bt_security { - uint8_t level; - uint8_t key_size; -}; -#define BT_SECURITY_SDP 0 -#define BT_SECURITY_LOW 1 -#define BT_SECURITY_MEDIUM 2 -#define BT_SECURITY_HIGH 3 - -#define BT_DEFER_SETUP 7 - -#define BT_FLUSHABLE 8 - -#define BT_FLUSHABLE_OFF 0 -#define BT_FLUSHABLE_ON 1 - -#define BT_POWER 9 -struct bt_power { - uint8_t force_active; -}; -#define BT_POWER_FORCE_ACTIVE_OFF 0 -#define BT_POWER_FORCE_ACTIVE_ON 1 - -#define BT_CHANNEL_POLICY 10 - -/* BR/EDR only (default policy) - * AMP controllers cannot be used. - * Channel move requests from the remote device are denied. - * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. - */ -#define BT_CHANNEL_POLICY_BREDR_ONLY 0 - -/* BR/EDR Preferred - * Allow use of AMP controllers. - * If the L2CAP channel is currently on AMP, move it to BR/EDR. - * Channel move requests from the remote device are allowed. - */ -#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 - -/* AMP Preferred - * Allow use of AMP controllers - * If the L2CAP channel is currently on BR/EDR and AMP controller - * resources are available, initiate a channel move to AMP. - * Channel move requests from the remote device are allowed. - * If the L2CAP socket has not been connected yet, try to create - * and configure the channel directly on an AMP controller rather - * than BR/EDR. - */ -#define BT_CHANNEL_POLICY_AMP_PREFERRED 2 - -#define BT_VOICE 11 -struct bt_voice { - uint16_t setting; -}; - -#define BT_SNDMTU 12 -#define BT_RCVMTU 13 - -#define BT_VOICE_TRANSPARENT 0x0003 -#define BT_VOICE_CVSD_16BIT 0x0060 - -/* Connection and socket states */ -enum { - BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ - BT_OPEN, - BT_BOUND, - BT_LISTEN, - BT_CONNECT, - BT_CONNECT2, - BT_CONFIG, - BT_DISCONN, - BT_CLOSED -}; - -/* Byte order conversions */ -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define htobs(d) (d) -#define htobl(d) (d) -#define htobll(d) (d) -#define btohs(d) (d) -#define btohl(d) (d) -#define btohll(d) (d) -#elif __BYTE_ORDER == __BIG_ENDIAN -#define htobs(d) bswap_16(d) -#define htobl(d) bswap_32(d) -#define htobll(d) bswap_64(d) -#define btohs(d) bswap_16(d) -#define btohl(d) bswap_32(d) -#define btohll(d) bswap_64(d) -#else -#error "Unknown byte order" -#endif - -/* Bluetooth unaligned access */ -#define bt_get_unaligned(ptr) \ -({ \ - struct __attribute__((packed)) { \ - typeof(*(ptr)) __v; \ - } *__p = (typeof(__p)) (ptr); \ - __p->__v; \ -}) - -#define bt_put_unaligned(val, ptr) \ -do { \ - struct __attribute__((packed)) { \ - typeof(*(ptr)) __v; \ - } *__p = (typeof(__p)) (ptr); \ - __p->__v = (val); \ -} while(0) - -#if __BYTE_ORDER == __LITTLE_ENDIAN -static inline uint64_t bt_get_le64(const void *ptr) -{ - return bt_get_unaligned((const uint64_t *) ptr); -} - -static inline uint64_t bt_get_be64(const void *ptr) -{ - return bswap_64(bt_get_unaligned((const uint64_t *) ptr)); -} - -static inline uint32_t bt_get_le32(const void *ptr) -{ - return bt_get_unaligned((const uint32_t *) ptr); -} - -static inline uint32_t bt_get_be32(const void *ptr) -{ - return bswap_32(bt_get_unaligned((const uint32_t *) ptr)); -} - -static inline uint16_t bt_get_le16(const void *ptr) -{ - return bt_get_unaligned((const uint16_t *) ptr); -} - -static inline uint16_t bt_get_be16(const void *ptr) -{ - return bswap_16(bt_get_unaligned((const uint16_t *) ptr)); -} - -static inline void bt_put_le64(uint64_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint64_t *) ptr); -} - -static inline void bt_put_be64(uint64_t val, const void *ptr) -{ - bt_put_unaligned(bswap_64(val), (uint64_t *) ptr); -} - -static inline void bt_put_le32(uint32_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint32_t *) ptr); -} - -static inline void bt_put_be32(uint32_t val, const void *ptr) -{ - bt_put_unaligned(bswap_32(val), (uint32_t *) ptr); -} - -static inline void bt_put_le16(uint16_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint16_t *) ptr); -} - -static inline void bt_put_be16(uint16_t val, const void *ptr) -{ - bt_put_unaligned(bswap_16(val), (uint16_t *) ptr); -} - -#elif __BYTE_ORDER == __BIG_ENDIAN -static inline uint64_t bt_get_le64(const void *ptr) -{ - return bswap_64(bt_get_unaligned((const uint64_t *) ptr)); -} - -static inline uint64_t bt_get_be64(const void *ptr) -{ - return bt_get_unaligned((const uint64_t *) ptr); -} - -static inline uint32_t bt_get_le32(const void *ptr) -{ - return bswap_32(bt_get_unaligned((const uint32_t *) ptr)); -} - -static inline uint32_t bt_get_be32(const void *ptr) -{ - return bt_get_unaligned((const uint32_t *) ptr); -} - -static inline uint16_t bt_get_le16(const void *ptr) -{ - return bswap_16(bt_get_unaligned((const uint16_t *) ptr)); -} - -static inline uint16_t bt_get_be16(const void *ptr) -{ - return bt_get_unaligned((const uint16_t *) ptr); -} - -static inline void bt_put_le64(uint64_t val, const void *ptr) -{ - bt_put_unaligned(bswap_64(val), (uint64_t *) ptr); -} - -static inline void bt_put_be64(uint64_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint64_t *) ptr); -} - -static inline void bt_put_le32(uint32_t val, const void *ptr) -{ - bt_put_unaligned(bswap_32(val), (uint32_t *) ptr); -} - -static inline void bt_put_be32(uint32_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint32_t *) ptr); -} - -static inline void bt_put_le16(uint16_t val, const void *ptr) -{ - bt_put_unaligned(bswap_16(val), (uint16_t *) ptr); -} - -static inline void bt_put_be16(uint16_t val, const void *ptr) -{ - bt_put_unaligned(val, (uint16_t *) ptr); -} -#else -#error "Unknown byte order" -#endif - -/* BD Address */ -typedef struct { - uint8_t b[6]; -} __attribute__((packed)) bdaddr_t; - -/* BD Address type */ -#define BDADDR_BREDR 0x00 -#define BDADDR_LE_PUBLIC 0x01 -#define BDADDR_LE_RANDOM 0x02 - -#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) -#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) -#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) - -/* Copy, swap, convert BD Address */ -static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) -{ - return memcmp(ba1, ba2, sizeof(bdaddr_t)); -} -static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src) -{ - memcpy(dst, src, sizeof(bdaddr_t)); -} - -void baswap(bdaddr_t *dst, const bdaddr_t *src); -bdaddr_t *strtoba(const char *str); -char *batostr(const bdaddr_t *ba); -int ba2str(const bdaddr_t *ba, char *str); -int str2ba(const char *str, bdaddr_t *ba); -int ba2oui(const bdaddr_t *ba, char *oui); -int bachk(const char *str); - -int baprintf(const char *format, ...); -int bafprintf(FILE *stream, const char *format, ...); -int basprintf(char *str, const char *format, ...); -int basnprintf(char *str, size_t size, const char *format, ...); - -void *bt_malloc(size_t size); -void bt_free(void *ptr); - -int bt_error(uint16_t code); -const char *bt_compidtostr(int id); - -typedef struct { - uint8_t data[16]; -} uint128_t; - -#if __BYTE_ORDER == __BIG_ENDIAN - -#define ntoh64(x) (x) - -static inline void ntoh128(const uint128_t *src, uint128_t *dst) -{ - memcpy(dst, src, sizeof(uint128_t)); -} - -static inline void btoh128(const uint128_t *src, uint128_t *dst) -{ - int i; - - for (i = 0; i < 16; i++) - dst->data[15 - i] = src->data[i]; -} - -#else - -static inline uint64_t ntoh64(uint64_t n) -{ - uint64_t h; - uint64_t tmp = ntohl(n & 0x00000000ffffffff); - - h = ntohl(n >> 32); - h |= tmp << 32; - - return h; -} - -static inline void ntoh128(const uint128_t *src, uint128_t *dst) -{ - int i; - - for (i = 0; i < 16; i++) - dst->data[15 - i] = src->data[i]; -} - -static inline void btoh128(const uint128_t *src, uint128_t *dst) -{ - memcpy(dst, src, sizeof(uint128_t)); -} - -#endif - -#define hton64(x) ntoh64(x) -#define hton128(x, y) ntoh128(x, y) -#define htob128(x, y) btoh128(x, y) - -#ifdef __cplusplus -} -#endif - -#endif /* __BLUETOOTH_H */ diff --git a/Development/Software/Controller API/makefile b/Development/Software/Controller API/makefile new file mode 100644 index 0000000000000000000000000000000000000000..6523f71d24e9ccde07abed862ba6c2347153ca9e --- /dev/null +++ b/Development/Software/Controller API/makefile @@ -0,0 +1,14 @@ +source: Source.cpp Server.o Client.o Capsule.o + g++ -o source Source.cpp Capsule.o Server.o Client.o -lbluetooth + +Server.o: Server.cpp + g++ -c Server.cpp -fpermissive + +Client.o: Client.cpp + g++ -c Client.cpp -fpermissive + +Capsule.o: Capsule.cpp + g++ -c Capsule.cpp -fpermissive + +clean: + rm *.o diff --git a/Development/Software/Controller API/rfcomm.h b/Development/Software/Controller API/rfcomm.h deleted file mode 100644 index ad6c0e1c3c3d3dd215c753e1822754a7863d1041..0000000000000000000000000000000000000000 --- a/Development/Software/Controller API/rfcomm.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> - * Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __RFCOMM_H -#define __RFCOMM_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/socket.h> - -/* RFCOMM defaults */ -#define RFCOMM_DEFAULT_MTU 127 - -#define RFCOMM_PSM 3 - -/* RFCOMM socket address */ -struct sockaddr_rc { - sa_family_t rc_family; - bdaddr_t rc_bdaddr; - uint8_t rc_channel; -}; - -/* RFCOMM socket options */ -#define RFCOMM_CONNINFO 0x02 -struct rfcomm_conninfo { - uint16_t hci_handle; - uint8_t dev_class[3]; -}; - -#define RFCOMM_LM 0x03 -#define RFCOMM_LM_MASTER 0x0001 -#define RFCOMM_LM_AUTH 0x0002 -#define RFCOMM_LM_ENCRYPT 0x0004 -#define RFCOMM_LM_TRUSTED 0x0008 -#define RFCOMM_LM_RELIABLE 0x0010 -#define RFCOMM_LM_SECURE 0x0020 - -/* RFCOMM TTY support */ -#define RFCOMM_MAX_DEV 256 - -#define RFCOMMCREATEDEV _IOW('R', 200, int) -#define RFCOMMRELEASEDEV _IOW('R', 201, int) -#define RFCOMMGETDEVLIST _IOR('R', 210, int) -#define RFCOMMGETDEVINFO _IOR('R', 211, int) - -struct rfcomm_dev_req { - int16_t dev_id; - uint32_t flags; - bdaddr_t src; - bdaddr_t dst; - uint8_t channel; -}; -#define RFCOMM_REUSE_DLC 0 -#define RFCOMM_RELEASE_ONHUP 1 -#define RFCOMM_HANGUP_NOW 2 -#define RFCOMM_TTY_ATTACHED 3 - -struct rfcomm_dev_info { - int16_t id; - uint32_t flags; - uint16_t state; - bdaddr_t src; - bdaddr_t dst; - uint8_t channel; -}; - -struct rfcomm_dev_list_req { - uint16_t dev_num; - struct rfcomm_dev_info dev_info[0]; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* __RFCOMM_H */ diff --git a/Development/Software/Controller API/socket.h b/Development/Software/Controller API/socket.h deleted file mode 100644 index 95ee26ab11c638c8e2a7efbf0636b5fb87868f55..0000000000000000000000000000000000000000 --- a/Development/Software/Controller API/socket.h +++ /dev/null @@ -1,285 +0,0 @@ -/* Declarations of socket constants, types, and functions. - Copyright (C) 1991-2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#ifndef _SYS_SOCKET_H -#define _SYS_SOCKET_H 1 - -#include <features.h> - -__BEGIN_DECLS - -#include <sys/uio.h> -#define __need_size_t -#include <stddef.h> -#ifdef __USE_GNU -/* Get the __sigset_t definition. */ -# include <bits/sigset.h> -#endif - - -/* This operating system-specific header file defines the SOCK_*, PF_*, - AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', - `struct msghdr', and `struct linger' types. */ -#include <bits/socket.h> - -#ifdef __USE_MISC -/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire - format in the grotty old 4.3 `talk' protocol. */ -struct osockaddr - { - unsigned short int sa_family; - unsigned char sa_data[14]; - }; -#endif - -/* The following constants should be used for the second parameter of - `shutdown'. */ -enum -{ - SHUT_RD = 0, /* No more receptions. */ -#define SHUT_RD SHUT_RD - SHUT_WR, /* No more transmissions. */ -#define SHUT_WR SHUT_WR - SHUT_RDWR /* No more receptions or transmissions. */ -#define SHUT_RDWR SHUT_RDWR -}; - -/* This is the type we use for generic socket address arguments. - - With GCC 2.7 and later, the funky union causes redeclarations or - uses with any of the listed types to be allowed without complaint. - G++ 2.7 does not support transparent unions so there we want the - old-style declaration, too. */ -#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU -# define __SOCKADDR_ARG struct sockaddr *__restrict -# define __CONST_SOCKADDR_ARG const struct sockaddr * -#else -/* Add more `struct sockaddr_AF' types here as necessary. - These are all the ones I found on NetBSD and Linux. */ -# define __SOCKADDR_ALLTYPES \ - __SOCKADDR_ONETYPE (sockaddr) \ - __SOCKADDR_ONETYPE (sockaddr_at) \ - __SOCKADDR_ONETYPE (sockaddr_ax25) \ - __SOCKADDR_ONETYPE (sockaddr_dl) \ - __SOCKADDR_ONETYPE (sockaddr_eon) \ - __SOCKADDR_ONETYPE (sockaddr_in) \ - __SOCKADDR_ONETYPE (sockaddr_in6) \ - __SOCKADDR_ONETYPE (sockaddr_inarp) \ - __SOCKADDR_ONETYPE (sockaddr_ipx) \ - __SOCKADDR_ONETYPE (sockaddr_iso) \ - __SOCKADDR_ONETYPE (sockaddr_ns) \ - __SOCKADDR_ONETYPE (sockaddr_un) \ - __SOCKADDR_ONETYPE (sockaddr_x25) - -# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__; -typedef union { __SOCKADDR_ALLTYPES - } __SOCKADDR_ARG __attribute__ ((__transparent_union__)); -# undef __SOCKADDR_ONETYPE -# define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__; -typedef union { __SOCKADDR_ALLTYPES - } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__)); -# undef __SOCKADDR_ONETYPE -#endif - -#ifdef __USE_GNU -/* For `recvmmsg' and `sendmmsg'. */ -struct mmsghdr - { - struct msghdr msg_hdr; /* Actual message header. */ - unsigned int msg_len; /* Number of received or sent bytes for the - entry. */ - }; -#endif - - -/* Create a new socket of type TYPE in domain DOMAIN, using - protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. - Returns a file descriptor for the new socket, or -1 for errors. */ -extern int socket (int __domain, int __type, int __protocol) __THROW; - -/* Create two new sockets, of type TYPE in domain DOMAIN and using - protocol PROTOCOL, which are connected to each other, and put file - descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero, - one will be chosen automatically. Returns 0 on success, -1 for errors. */ -extern int socketpair (int __domain, int __type, int __protocol, - int __fds[2]) __THROW; - -/* Give the socket FD the local address ADDR (which is LEN bytes long). */ -extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) - __THROW; - -/* Put the local address of FD into *ADDR and its length in *LEN. */ -extern int getsockname (int __fd, __SOCKADDR_ARG __addr, - socklen_t *__restrict __len) __THROW; - -/* Open a connection on socket FD to peer at ADDR (which LEN bytes long). - For connectionless socket types, just set the default address to send to - and the only address from which to accept transmissions. - Return 0 on success, -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); - -/* Put the address of the peer connected to socket FD into *ADDR - (which is *LEN bytes long), and its actual length into *LEN. */ -extern int getpeername (int __fd, __SOCKADDR_ARG __addr, - socklen_t *__restrict __len) __THROW; - - -/* Send N bytes of BUF to socket FD. Returns the number sent or -1. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags); - -/* Read N bytes into BUF from socket FD. - Returns the number read or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); - -/* Send N bytes of BUF on socket FD to peer at address ADDR (which is - ADDR_LEN bytes long). Returns the number sent, or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t sendto (int __fd, const void *__buf, size_t __n, - int __flags, __CONST_SOCKADDR_ARG __addr, - socklen_t __addr_len); - -/* Read N bytes into BUF through socket FD. - If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of - the sender, and store the actual size of the address in *ADDR_LEN. - Returns the number of bytes read or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n, - int __flags, __SOCKADDR_ARG __addr, - socklen_t *__restrict __addr_len); - - -/* Send a message described MESSAGE on socket FD. - Returns the number of bytes sent, or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t sendmsg (int __fd, const struct msghdr *__message, - int __flags); - -#ifdef __USE_GNU -/* Send a VLEN messages as described by VMESSAGES to socket FD. - Returns the number of datagrams successfully written or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int sendmmsg (int __fd, struct mmsghdr *__vmessages, - unsigned int __vlen, int __flags); -#endif - -/* Receive a message as described by MESSAGE from socket FD. - Returns the number of bytes read or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags); - -#ifdef __USE_GNU -/* Receive up to VLEN messages as described by VMESSAGES from socket FD. - Returns the number of messages received or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int recvmmsg (int __fd, struct mmsghdr *__vmessages, - unsigned int __vlen, int __flags, - const struct timespec *__tmo); -#endif - - -/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL - into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's - actual length. Returns 0 on success, -1 for errors. */ -extern int getsockopt (int __fd, int __level, int __optname, - void *__restrict __optval, - socklen_t *__restrict __optlen) __THROW; - -/* Set socket FD's option OPTNAME at protocol level LEVEL - to *OPTVAL (which is OPTLEN bytes long). - Returns 0 on success, -1 for errors. */ -extern int setsockopt (int __fd, int __level, int __optname, - const void *__optval, socklen_t __optlen) __THROW; - - -/* Prepare to accept connections on socket FD. - N connection requests will be queued before further requests are refused. - Returns 0 on success, -1 for errors. */ -extern int listen (int __fd, int __n) __THROW; - -/* Await a connection on socket FD. - When a connection arrives, open a new socket to communicate with it, - set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting - peer and *ADDR_LEN to the address's actual length, and return the - new socket's descriptor, or -1 for errors. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int accept (int __fd, __SOCKADDR_ARG __addr, - socklen_t *__restrict __addr_len); - -#ifdef __USE_GNU -/* Similar to 'accept' but takes an additional parameter to specify flags. - - This function is a cancellation point and therefore not marked with - __THROW. */ -extern int accept4 (int __fd, __SOCKADDR_ARG __addr, - socklen_t *__restrict __addr_len, int __flags); -#endif - -/* Shut down all or part of the connection open on socket FD. - HOW determines what to shut down: - SHUT_RD = No more receptions; - SHUT_WR = No more transmissions; - SHUT_RDWR = No more receptions or transmissions. - Returns 0 on success, -1 for errors. */ -extern int shutdown (int __fd, int __how) __THROW; - - -#ifdef __USE_XOPEN2K -/* Determine wheter socket is at a out-of-band mark. */ -extern int sockatmark (int __fd) __THROW; -#endif - - -#ifdef __USE_MISC -/* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>; - returns 1 if FD is open on an object of the indicated type, 0 if not, - or -1 for errors (setting errno). */ -extern int isfdtype (int __fd, int __fdtype) __THROW; -#endif - - -/* Define some macros helping to catch buffer overflows. */ -#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function -# include <bits/socket2.h> -#endif - -__END_DECLS - -#endif /* sys/socket.h */