Diffstat (limited to 'gammu/emb/common/device/bluetoth/blue_w32.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/device/bluetoth/blue_w32.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gammu/emb/common/device/bluetoth/blue_w32.c b/gammu/emb/common/device/bluetoth/blue_w32.c index a631c9f..8a367f4 100644 --- a/gammu/emb/common/device/bluetoth/blue_w32.c +++ b/gammu/emb/common/device/bluetoth/blue_w32.c | |||
@@ -59,115 +59,115 @@ GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device) | |||
59 | dbgprintf("Remote Bluetooth device is %04x%08x\n", | 59 | dbgprintf("Remote Bluetooth device is %04x%08x\n", |
60 | GET_NAP(sab.btAddr), GET_SAP(sab.btAddr)); | 60 | GET_NAP(sab.btAddr), GET_SAP(sab.btAddr)); |
61 | 61 | ||
62 | if (connect (d->hPhone, (struct sockaddr *)&sab, sizeof(sab)) != 0) { | 62 | if (connect (d->hPhone, (struct sockaddr *)&sab, sizeof(sab)) != 0) { |
63 | i = GetLastError(); | 63 | i = GetLastError(); |
64 | GSM_OSErrorInfo(s, "Connect in bluetooth_open"); | 64 | GSM_OSErrorInfo(s, "Connect in bluetooth_open"); |
65 | if (i == 10060) return ERR_TIMEOUT; //remote device failed to respond | 65 | if (i == 10060) return ERR_TIMEOUT; //remote device failed to respond |
66 | if (i == 10050) return ERR_DEVICENOTWORK; //socket operation connected with dead network | 66 | if (i == 10050) return ERR_DEVICENOTWORK; //socket operation connected with dead network |
67 | //noauth | 67 | //noauth |
68 | close(d->hPhone); | 68 | close(d->hPhone); |
69 | return ERR_UNKNOWN; | 69 | return ERR_UNKNOWN; |
70 | } | 70 | } |
71 | 71 | ||
72 | return ERR_NONE; | 72 | return ERR_NONE; |
73 | } | 73 | } |
74 | 74 | ||
75 | #ifdef BLUETOOTH_RF_SEARCHING | 75 | #ifdef BLUETOOTH_RF_SEARCHING |
76 | 76 | ||
77 | #pragma comment(lib, "irprops.lib") | 77 | #pragma comment(lib, "irprops.lib") |
78 | #pragma comment(lib, "ws2_32.lib") | 78 | #pragma comment(lib, "ws2_32.lib") |
79 | 79 | ||
80 | static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, char *address, WSAPROTOCOL_INFO *protocolInfo) | 80 | static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, char *address, WSAPROTOCOL_INFO *protocolInfo) |
81 | { | 81 | { |
82 | GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth; | 82 | GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth; |
83 | WSAQUERYSET querySet; | 83 | WSAQUERYSET querySet; |
84 | DWORD flags; | 84 | DWORD flags; |
85 | GUID protocol; | 85 | GUID protocol; |
86 | int i, result; | 86 | int i, result; |
87 | BYTE buffer[2000]; | 87 | BYTE buffer[2000]; |
88 | char addressAsString[1000]; | 88 | char addressAsString[1000]; |
89 | DWORD bufferLength, addressSize; | 89 | DWORD bufferLength, addressSize; |
90 | WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer; | 90 | WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer; |
91 | HANDLE handle; | 91 | Qt::HANDLE handle; |
92 | GSM_Error error; | 92 | GSM_Error error; |
93 | 93 | ||
94 | memset(&querySet, 0, sizeof(querySet)); | 94 | memset(&querySet, 0, sizeof(querySet)); |
95 | querySet.dwSize = sizeof(querySet); | 95 | querySet.dwSize = sizeof(querySet); |
96 | protocol = L2CAP_PROTOCOL_UUID; | 96 | protocol = L2CAP_PROTOCOL_UUID; |
97 | querySet.lpServiceClassId = &protocol; | 97 | querySet.lpServiceClassId = &protocol; |
98 | querySet.dwNameSpace = NS_BTH; | 98 | querySet.dwNameSpace = NS_BTH; |
99 | querySet.lpszContext = address; | 99 | querySet.lpszContext = address; |
100 | 100 | ||
101 | flags = LUP_FLUSHCACHE | LUP_RETURN_NAME | | 101 | flags = LUP_FLUSHCACHE | LUP_RETURN_NAME | |
102 | LUP_RETURN_TYPE | LUP_RETURN_ADDR | | 102 | LUP_RETURN_TYPE | LUP_RETURN_ADDR | |
103 | LUP_RETURN_BLOB | LUP_RETURN_COMMENT; | 103 | LUP_RETURN_BLOB | LUP_RETURN_COMMENT; |
104 | 104 | ||
105 | result = WSALookupServiceBegin(&querySet, flags, &handle); | 105 | result = WSALookupServiceBegin(&querySet, flags, &handle); |
106 | if (result != 0) return ERR_UNKNOWN; | 106 | if (result != 0) return ERR_UNKNOWN; |
107 | 107 | ||
108 | bufferLength = sizeof(buffer); | 108 | bufferLength = sizeof(buffer); |
109 | while (1) { | 109 | while (1) { |
110 | result = WSALookupServiceNext(handle, flags, &bufferLength, pResults); | 110 | result = WSALookupServiceNext(handle, flags, &bufferLength, pResults); |
111 | if (result != 0) break; | 111 | if (result != 0) break; |
112 | addressSize = sizeof(addressAsString); | 112 | addressSize = sizeof(addressAsString); |
113 | addressAsString[0] = 0; | 113 | addressAsString[0] = 0; |
114 | if (WSAAddressToString(pResults->lpcsaBuffer->RemoteAddr.lpSockaddr, | 114 | if (WSAAddressToString(pResults->lpcsaBuffer->RemoteAddr.lpSockaddr, |
115 | pResults->lpcsaBuffer->RemoteAddr.iSockaddrLength, protocolInfo, | 115 | pResults->lpcsaBuffer->RemoteAddr.iSockaddrLength, protocolInfo, |
116 | addressAsString,&addressSize)==0) { | 116 | addressAsString,&addressSize)==0) { |
117 | smprintf(s, "%s - ", addressAsString); | 117 | smprintf(s, "%s - ", addressAsString); |
118 | } | 118 | } |
119 | smprintf(s, "\"%s\"\n", pResults->lpszServiceInstanceName); | 119 | smprintf(s, "\"%s\"\n", pResults->lpszServiceInstanceName); |
120 | if (addressAsString[0] != 0) { | 120 | if (addressAsString[0] != 0) { |
121 | for (i=strlen(addressAsString)-1;i>0;i--) { | 121 | for (i=strlen(addressAsString)-1;i>0;i--) { |
122 | if (addressAsString[i] == ':') break; | 122 | if (addressAsString[i] == ':') break; |
123 | } | 123 | } |
124 | if (bluetooth_checkservicename(s, pResults->lpszServiceInstanceName) == ERR_NONE) { | 124 | if (bluetooth_checkservicename(s, pResults->lpszServiceInstanceName) == ERR_NONE) { |
125 | error = bluetooth_connect(s,atoi(addressAsString+i+1),address+1); | 125 | error = bluetooth_connect(s,atoi(addressAsString+i+1),address+1); |
126 | result = WSALookupServiceEnd(handle); | 126 | result = WSALookupServiceEnd(handle); |
127 | return error; | 127 | return error; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | result = WSALookupServiceEnd(handle); | 131 | result = WSALookupServiceEnd(handle); |
132 | return ERR_NOTSUPPORTED; | 132 | return ERR_NOTSUPPORTED; |
133 | } | 133 | } |
134 | 134 | ||
135 | GSM_Error bluetooth_findchannel(GSM_StateMachine *s) | 135 | GSM_Error bluetooth_findchannel(GSM_StateMachine *s) |
136 | { | 136 | { |
137 | GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth; | 137 | GSM_Device_BlueToothData *d = &s->Device.Data.BlueTooth; |
138 | WSADATA wsaData; | 138 | WSADATA wsaData; |
139 | int i, protocolInfoSize, result; | 139 | int i, protocolInfoSize, result; |
140 | WSAPROTOCOL_INFO protocolInfo; | 140 | WSAPROTOCOL_INFO protocolInfo; |
141 | HANDLE handle; | 141 | Qt::HANDLE handle; |
142 | DWORD flags; | 142 | DWORD flags; |
143 | WSAQUERYSET querySet; | 143 | WSAQUERYSET querySet; |
144 | BYTE buffer[2000]; | 144 | BYTE buffer[2000]; |
145 | char addressAsString[1000]; | 145 | char addressAsString[1000]; |
146 | DWORD bufferLength, addressSize; | 146 | DWORD bufferLength, addressSize; |
147 | WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer; | 147 | WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer; |
148 | GSM_Error error; | 148 | GSM_Error error; |
149 | 149 | ||
150 | if (WSAStartup(MAKEWORD(2,2), &wsaData)!=0x00) return ERR_DEVICENODRIVER; | 150 | if (WSAStartup(MAKEWORD(2,2), &wsaData)!=0x00) return ERR_DEVICENODRIVER; |
151 | 151 | ||
152 | d->hPhone = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); | 152 | d->hPhone = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); |
153 | if (d->hPhone == INVALID_SOCKET) { | 153 | if (d->hPhone == INVALID_SOCKET) { |
154 | i = GetLastError(); | 154 | i = GetLastError(); |
155 | GSM_OSErrorInfo(s, "Socket in bluetooth_open"); | 155 | GSM_OSErrorInfo(s, "Socket in bluetooth_open"); |
156 | if (i == 10041) return ERR_DEVICENODRIVER;//unknown socket type | 156 | if (i == 10041) return ERR_DEVICENODRIVER;//unknown socket type |
157 | return ERR_UNKNOWN; | 157 | return ERR_UNKNOWN; |
158 | } | 158 | } |
159 | 159 | ||
160 | protocolInfoSize = sizeof(protocolInfo); | 160 | protocolInfoSize = sizeof(protocolInfo); |
161 | if (getsockopt(d->hPhone, SOL_SOCKET, SO_PROTOCOL_INFO, | 161 | if (getsockopt(d->hPhone, SOL_SOCKET, SO_PROTOCOL_INFO, |
162 | (char*)&protocolInfo, &protocolInfoSize) != 0) | 162 | (char*)&protocolInfo, &protocolInfoSize) != 0) |
163 | { | 163 | { |
164 | close(d->hPhone); | 164 | close(d->hPhone); |
165 | return ERR_UNKNOWN; | 165 | return ERR_UNKNOWN; |
166 | } | 166 | } |
167 | close(d->hPhone); | 167 | close(d->hPhone); |
168 | 168 | ||
169 | if (!strcmp(s->CurrentConfig->Device,"com2:")) { | 169 | if (!strcmp(s->CurrentConfig->Device,"com2:")) { |
170 | bufferLength = sizeof(buffer); | 170 | bufferLength = sizeof(buffer); |
171 | 171 | ||
172 | flags = LUP_RETURN_NAME | LUP_CONTAINERS | | 172 | flags = LUP_RETURN_NAME | LUP_CONTAINERS | |
173 | LUP_RETURN_ADDR | LUP_FLUSHCACHE | | 173 | LUP_RETURN_ADDR | LUP_FLUSHCACHE | |