Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Работа с IrDA и BlueTooth, Поделитесь опытом работы и наработками. 
:(
    Опции темы
ArnoldLane
Дата 4.9.2005, 13:19 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 26
Регистрация: 14.6.2005

Репутация: нет
Всего: нет



Есть задание - прога должна уметь общаться с окружающим миром с помощью инфракрасного соединения и технологии Bluetooth. Нахожусь в самом начале пути. Посему буду примного благодарен за любые крохи знаний по данной проблеме. Ссылки, компоненты, исходники, просто советы, все сгодиться.
Заранее всем "непрошедщим мимо" огромное спасибо.
PM MAIL   Вверх
noopik)
Дата 4.9.2005, 20:54 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











C Bluetooth и IrDA в Windows, начиная с версии 5.1 (ХР) можно достаточно просто работать через Сокеты.
Цитата

To enable communication between two Bluetooth devices, you can create a connection by creating client and server sockets. The Bluetooth server socket must be configured to listen for incoming connection and accept a client socket. The Bluetooth client socket must know the address of the Bluetooth device to connect to, before it sends a connection request.

Microsoft® Windows® CE implementation of Bluetooth allows you to create a piconet. As per the Bluetooth specification, a master device can connect with seven active slave devices. For more information about piconet, see the Bluetooth Core Specification at this Official Bluetooth Wireless Info Web site.

You can also create a connection by using the COM Port emulator facility that ships with Microsoft Windows CE. For more information about using this facility to create connections, see Creating a Connection to a Remote Device Using a Virtual COM Port.

Note  Error handling has been omitted in this topic for clarity.
Before you create a connection between two Bluetooth devices, you must have the following information:

The address of the remote Bluetooth device to query, as a BT_ADDR type, as defined in Ws2bth.h:
typedef ULONGLONG bt_addr, *pbt_addr, BT_ADDR, *PBT_ADDR;
Note  This requirement is for client ports only.
Service identifier as a GUID type variable.
- or -

RFCOMM channel (between 1 and 31).

The Ssa sample that ships with Windows CE, contains source code for creating a Bluetooth connection by using Winsock. For more information about this sample, see Winsock Interface Sample.

To create a client socket

Prepare the caller application by providing data about Winsock such as the version and implementation details. This data can be retrieved by calling the WSAStartup function as the following example code shows.
WSADATA wsd;
WSAStartup (MAKEWORD(1,0), &wsd);
Create a Bluetooth socket by calling the socket function, as the following example code shows.
SOCKET client_socket = socket (AF_BT, SOCK_STREAM, BTHPROTO_RFCOMM);
The parameter values for the socket function configures this socket for Bluetooth services.

Store information about the remote Bluetooth device that the client is connecting to, by configuring a SOCKADDR_BTH structure.
Create and initialize a SOCKADDR_BTH variable as the following example code shows:
SOCKADDR_BTH sa;
memset (&sa, 0, sizeof(sa));
Set the btAddr member to a BT_ADDR variable that contains the address of the target device.
sa.btAddr = b; //b is a BT_ADDR variable
Your application can accept the device address as a string but must convert the address and store it in a variable of type BT_ADDR.

If the service identifier is available, then set the serviceClassId member of SOCKADDR_BTH to the GUID of the RFCOMM-based service. In this case, the client performs an SDP query and then uses the resulting server channel.
- or-

If you want to use a hard-coded channel number, set the port member of SOCKADDR_BTH to the server channel number as the following example code shows.

sa.port = channel & 0xff;
Connect to the Bluetooth socket, created in step 2, by calling the connect function, as the following example code shows.
if (connect (client_socket, (SOCKADDR *)&sa, sizeof(sa)))
{
  //Perform error handling.
  closesocket (client_socket);
  return 0;
}
Specify the attributes of the target device by passing a SOCKADDR_BTH, configured in step 3.

After the connection is established, you can communicate with the target device by sending and receiving data.

To close the connection to the target device, call the closesocket function to close the Bluetooth socket. Also, ensure that you release the socket by calling the CloseHandle function, as the following example code shows.
closesocket(client_socket);
CloseHandle ((LPVOID)client_socket);
To terminate the use of Winsock services, call the WSACleanup function. There must be a call to WSACleanup for every successful call to WSAStartup made by an application.
To create a server socket



  Вверх
ArnoldLane
Дата 5.9.2005, 12:43 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 26
Регистрация: 14.6.2005

Репутация: нет
Всего: нет



Большое спасибо. Попробую разобраться. О результатах сообщу. Надеюсь, что все действительно будет так легко, как кажется.
PM MAIL   Вверх
maddoc
Дата 5.9.2005, 17:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 364
Регистрация: 11.5.2005

Репутация: нет
Всего: 1



а вот у меня такая же проблемка, только мне нужно под все винды (ну хотя бы с 98 или NT)
Добавлено @ 17:23
то есть минимум


--------------------
"Безвыходных положений не бывает" (с) Камасутра
PM MAIL   Вверх
noopik)
Дата 5.9.2005, 21:44 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











Цитата
а вот у меня такая же проблемка, только мне нужно под все винды (ну хотя бы с 98 или NT)

нууу... батенька, давно пора перебираться на XP )) 98 must die forever))
Сейчас, по-моему довольно редко встретишь компьютер, с основной ОС - win98.
В 98ой с Bluetooth & IrDA работать будет весьма проблематачино. Единственное решение - работать через сторонние драйвера...
  Вверх
maddoc
Дата 5.9.2005, 22:01 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 364
Регистрация: 11.5.2005

Репутация: нет
Всего: 1



нет мне нужно не для себя, а для работы, а заказчик, как вы понимаете, бывает разный, да и начальство обычно на его стороне.
так вот если скажут надо - то ничего тут не поделаеш, и под дос придется писать.
а сторонних не нужны, нужны собственные, вот.
так что буду благодарен за любую помощь.


--------------------
"Безвыходных положений не бывает" (с) Камасутра
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "С++ Builder"
Rrader

Запрещается!

1. Публиковать ссылки на вскрытые компоненты

2. Обсуждать взлом компонентов и делиться вскрытыми компонентами

  • Литературу по С++ Builder обсуждаем здесь
  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Настоятельно рекомендуем заглянуть в DRKB (Delphi Russian Knowledge Base) - крупнейший в рунете сборник материалов по Дельфи


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Rrader.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C++ Builder | Следующая тема »


 




[ Время генерации скрипта: 0.0434 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.