Kaydet (Commit) 3cadf6de authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Added bluez_bluetooth headers as a module.

Change-Id: Id9f4e59b5c46c7bee3cf0b129f523d963c0407a6
üst f2b1841a
......@@ -37,6 +37,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\
basic \
bean \
binaryurp \
bluez_bluetooth \
canvas \
chart2 \
configmgr \
......
......@@ -430,6 +430,7 @@ $(eval $(call gb_Helper_register_libraries,PLAINLIBS_OOO, \
avmediagst \
avmediagst_0_10 \
avmediawin \
bluez_bluetooth \
cached1 \
collator_data \
dbpool2 \
......
......@@ -40,6 +40,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
basic \
bean \
binaryurp \
bluez_bluetooth \
canvas \
chart2 \
clucene \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.libreoffice.impressremote.communication;
import java.net.Socket;
import java.util.UUID;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
/**
* Standard Network client. Connects to a server using Sockets.
*
* @author Andrzej J.R. Hunt
*/
public class BluetoothClient extends Client {
private static final int PORT = 5;
private Socket mSocket;
public BluetoothClient(String bluetoothAddress, Context aContext) {
super(aContext);
try {
BluetoothAdapter aAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice aDevice = aAdapter
.getRemoteDevice(bluetoothAddress);
BluetoothSocket aSocket = aDevice
.createRfcommSocketToServiceRecord(UUID
.fromString("00001101-0000-1000-8000-00805f9b34fb"));
aSocket.connect();
} catch (Exception e) {
e.printStackTrace();
}
// BluetoothSocket aSocket = new BluetoothClient(bluetoothAddress, aContext)
// .createRfcommSocketToServiceRecord(UUID
// .fromString("00001101-0000-1000-8000-00805F9B34F
// }
// try {
// mSocket = new Socket(ipAddress, PORT);
// mInputStream = mSocket.getInputStream();
// mReader = new BufferedReader(new InputStreamReader(mInputStream,
// CHARSET));
// mOutputStream = mSocket.getOutputStream();
// // Pairing.
// Random aRandom = new Random();
// String aPin = "" + (aRandom.nextInt(9000) + 1000);
// while (aPin.length() < 4) {
// aPin = "0" + aPin; // Add leading zeros if necessary
// }
// Intent aIntent = new Intent(
// CommunicationService.MSG_PAIRING_STARTED);
// aIntent.putExtra("PIN", aPin);
// mPin = aPin;
// LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
// // Send out
// String aName = CommunicationService.getDeviceName(); // TODO: get the proper name
// sendCommand("LO_SERVER_CLIENT_PAIR\n" + aName + "\n" + aPin
// + "\n\n");
//
// // Wait until we get the appropriate string back...
// System.out.println("SF:waiting");
// String aTemp = mReader.readLine();
// System.out.println("SF:waited");
// if (!aTemp.equals("LO_SERVER_SERVER_PAIRED")) {
// return;
// } else {
// aIntent = new Intent(
// CommunicationService.MSG_PAIRING_SUCCESSFUL);
// LocalBroadcastManager.getInstance(mContext).sendBroadcast(
// aIntent);
// }
// while (mReader.readLine().length() != 0) {
// // Get rid of extra lines
// System.out.println("SF: empty line");
// }
// System.out.println("SD: empty");
// startListening();
// } catch (UnknownHostException e) {
// // TODO Tell the user we have a problem
// e.printStackTrace();
// } catch (IOException e) {
// // TODO As above
// e.printStackTrace();
// }
}
@Override
public void closeConnection() {
// try {
// if (mSocket != null)
// mSocket.close();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
......@@ -81,12 +81,14 @@ public class CommunicationService extends Service implements Runnable {
case NETWORK:
mClient = new NetworkClient(
mServerDesired.getAddress(), this);
mTransmitter = new Transmitter(mClient);
mClient.setReceiver(mReceiver);
break;
case BLUETOOTH:
mClient = new BluetoothClient(
mServerDesired.getAddress(), this);
break;
}
mTransmitter = new Transmitter(mClient);
mClient.setReceiver(mReceiver);
mState = State.CONNECTED;
}
}
......
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Peter Foley <pefoley2@verizon.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
$(eval $(call gb_Module_Module,bluez_bluetooth))
$(eval $(call gb_Module_add_targets,bluez_bluetooth,\
Package_inc \
))
# vim: set noet sw=4 ts=4:
\ No newline at end of file
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Initial Developer of the Original Code is
# Peter Foley <pefoley2@verizon.net>
# Portions created by the Initial Developer are Copyright (C) 2011 the
# Initial Developer. All Rights Reserved.
#
# Major Contributor(s):
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
#
$(eval $(call gb_Package_Package,bluez_bluetooth_inc,$(SRCDIR)/bluez_bluetooth/inc))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/bluetooth.h,bluetooth/bluetooth.h))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/hci.h,bluetooth/hci.h))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/hci_lib.h,bluetooth/hci_lib.h))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/l2cap.h,bluetooth/l2cap.h))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/rfcomm.h,bluetooth/rfcomm.h))
$(eval $(call gb_Package_add_file,bluez_bluetooth_inc,inc/bluetooth/sco.h,bluetooth/sco.h))
# vim: set noet sw=4 ts=4:
\ No newline at end of file
Cleaned linux bluez headers.
Originally gotten from:
http://gitorious.org/0xdroid/system_bluetooth/trees/59ca0be6dc8ef3f30f8f863d8fb805a55bf12fe5/bluez-clean-headers
......@@ -58,11 +58,13 @@
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
#ifdef __cplusplus
#endif
typedef struct {
uint8_t b[6];
} __attribute__((packed)) bdaddr_t;
static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
typedef struct
{
memcpy(dst, src, sizeof(bdaddr_t));
uint8_t b[6];
} __attribute__ ((packed)) bdaddr_t;
static inline void
bacpy (bdaddr_t * dst, const bdaddr_t * src)
{
memcpy (dst, src, sizeof (bdaddr_t));
}
#endif
This diff is collapsed.
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Bluez header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to Android. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __HCI_LIB_H
#define __HCI_LIB_H
#ifdef __cplusplus
#endif
#ifdef __cplusplus
#endif
static inline int
hci_test_bit (int nr, void *addr)
{
return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
}
#endif
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __L2CAP_H
#define __L2CAP_H
#ifdef __cplusplus
#endif
#include <sys/socket.h>
#define L2CAP_DEFAULT_MTU 672
#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF
#define L2CAP_CONN_TIMEOUT (HZ * 40)
#define L2CAP_OPTIONS 0x01
#define L2CAP_CONNINFO 0x02
#define L2CAP_LM 0x03
#define L2CAP_LM_MASTER 0x0001
#define L2CAP_LM_AUTH 0x0002
#define L2CAP_LM_ENCRYPT 0x0004
#define L2CAP_LM_TRUSTED 0x0008
#define L2CAP_LM_RELIABLE 0x0010
#define L2CAP_LM_SECURE 0x0020
#define L2CAP_LM_FLUSHABLE 0x0040
#define L2CAP_COMMAND_REJ 0x01
#define L2CAP_CONN_REQ 0x02
#define L2CAP_CONN_RSP 0x03
#define L2CAP_CONF_REQ 0x04
#define L2CAP_CONF_RSP 0x05
#define L2CAP_DISCONN_REQ 0x06
#define L2CAP_DISCONN_RSP 0x07
#define L2CAP_ECHO_REQ 0x08
#define L2CAP_ECHO_RSP 0x09
#define L2CAP_INFO_REQ 0x0a
#define L2CAP_INFO_RSP 0x0b
#define L2CAP_HDR_SIZE 4
#define L2CAP_CMD_HDR_SIZE 4
#define L2CAP_CMD_REJ_SIZE 2
#define L2CAP_CONN_REQ_SIZE 4
#define L2CAP_CONN_RSP_SIZE 8
#define L2CAP_CR_SUCCESS 0x0000
#define L2CAP_CR_PEND 0x0001
#define L2CAP_CR_BAD_PSM 0x0002
#define L2CAP_CR_SEC_BLOCK 0x0003
#define L2CAP_CR_NO_MEM 0x0004
#define L2CAP_CS_NO_INFO 0x0000
#define L2CAP_CS_AUTHEN_PEND 0x0001
#define L2CAP_CS_AUTHOR_PEND 0x0002
#define L2CAP_CONF_REQ_SIZE 4
#define L2CAP_CONF_RSP_SIZE 6
#define L2CAP_CONF_SUCCESS 0x0000
#define L2CAP_CONF_UNACCEPT 0x0001
#define L2CAP_CONF_REJECT 0x0002
#define L2CAP_CONF_UNKNOWN 0x0003
#define L2CAP_CONF_OPT_SIZE 2
#define L2CAP_CONF_MTU 0x01
#define L2CAP_CONF_FLUSH_TO 0x02
#define L2CAP_CONF_QOS 0x03
#define L2CAP_CONF_RFC 0x04
#define L2CAP_CONF_RFC_MODE 0x04
#define L2CAP_CONF_MAX_SIZE 22
#define L2CAP_MODE_BASIC 0x00
#define L2CAP_MODE_RETRANS 0x01
#define L2CAP_MODE_FLOWCTL 0x02
#define L2CAP_DISCONN_REQ_SIZE 4
#define L2CAP_DISCONN_RSP_SIZE 4
#define L2CAP_INFO_REQ_SIZE 2
#define L2CAP_INFO_RSP_SIZE 4
#define L2CAP_IT_CL_MTU 0x0001
#define L2CAP_IT_FEAT_MASK 0x0002
#define L2CAP_IR_SUCCESS 0x0000
#define L2CAP_IR_NOTSUPP 0x0001
#ifdef __cplusplus
#endif
struct sockaddr_l2
{
sa_family_t l2_family;
unsigned short l2_psm;
bdaddr_t l2_bdaddr;
};
#endif
......@@ -38,9 +38,10 @@
#define RFCOMM_TTY_ATTACHED 3
#ifdef __cplusplus
#endif
struct sockaddr_rc {
sa_family_t rc_family;
bdaddr_t rc_bdaddr;
uint8_t rc_channel;
struct sockaddr_rc
{
sa_family_t rc_family;
bdaddr_t rc_bdaddr;
uint8_t rc_channel;
};
#endif
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Bluez header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to Android. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __SCO_H
#define __SCO_H
#ifdef __cplusplus
#endif
#define SCO_DEFAULT_MTU 500
#define SCO_DEFAULT_FLUSH_TO 0xFFFF
#define SCO_CONN_TIMEOUT (HZ * 40)
#define SCO_DISCONN_TIMEOUT (HZ * 2)
#define SCO_CONN_IDLE_TIMEOUT (HZ * 60)
#define SCO_OPTIONS 0x01
#define SCO_CONNINFO 0x02
#ifdef __cplusplus
#endif
struct sockaddr_sco
{
sa_family_t sco_family;
bdaddr_t sco_bdaddr;
uint16_t sco_pkt_type;
};
#endif
......@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_sdi_headers,sd,\
$(eval $(call gb_Library_use_packages,sd,\
animations_inc \
bluez_bluetooth_inc \
))
$(eval $(call gb_Library_set_include,sd,\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment