AusweisApp2
CyberJackWaveDevice.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 
10 #include <QBluetoothDeviceInfo>
11 #include <QLowEnergyCharacteristic>
12 #include <QLowEnergyController>
13 #include <QLowEnergyService>
14 
15 
16 namespace governikus
17 {
18 
20  : public QObject
21 {
22  Q_OBJECT
23 
24  private:
25  /*
26  * This is the maximum number of bytes arriving in one incoming response block
27  */
28  static int INPUT_BLOCK_SIZE;
29 
30  /*
31  * This is the maximum number of bytes to send in one outgoing request block
32  */
33  static int OUTPUT_BLOCK_SIZE;
34 
35  /*
36  * This is the service UUID of the LE service providing the "SIM Access Profile"
37  */
38  static QBluetoothUuid SAP_SERVICE_UUID;
39 
40  /*
41  * This is the characteristic UUID of the SAP service for outgoing requests
42  */
43  static QBluetoothUuid WRITE_CHARACTERISTIC_UUID;
44 
45  /*
46  * This is the characteristic UUID of the SAP service for incoming responses
47  */
48  static QBluetoothUuid READ_CHARACTERISTIC_UUID;
49 
50  /*
51  * This is the characteristic UUID of the SAP service for status indications
52  */
53  static QBluetoothUuid STATUS_CHARACTERISTIC_UUID;
54 
55  QBluetoothDeviceInfo mDeviceInfo;
56  QLowEnergyController mLeController;
57  QScopedPointer<QLowEnergyService> mSapService;
58  QLowEnergyCharacteristic mStatusCharacteristic, mReadCharacteristic, mWriteCharacteristic;
59 
60  QLowEnergyService::WriteMode determineWriteMode(int pBlockIndex);
61 
62  private Q_SLOTS:
63  void onConnectedDevice();
64  void onDisconnectedDevice();
65  void onDeviceError(QLowEnergyController::Error pError);
66  void onDeviceStateChanged(QLowEnergyController::ControllerState pState);
67  void onServiceDiscoveryFinished();
68  void onServiceStateChanged(QLowEnergyService::ServiceState pState);
69  void onServiceError(QLowEnergyService::ServiceError pError);
70  void onCharacteristicChanged(const QLowEnergyCharacteristic& pCharacteristic, const QByteArray& pNewValue);
71 
72  public:
73  CyberJackWaveDevice(const QBluetoothDeviceInfo& pDeviceInfo);
75 
76  QString getName() const;
77  void setDeviceInfo(const QBluetoothDeviceInfo& pInfo);
78 
79  bool isValid() const;
80 
81  bool write(const QByteArray& pValue);
82 
83  public Q_SLOTS:
87  void initialize();
88 
92  void disconnectFromDevice();
93 
94  Q_SIGNALS:
95  void fireInitialized(const QBluetoothDeviceInfo& pInfo);
96  void fireDisconnected(const QBluetoothDeviceInfo& pInfo);
97  void fireError(QLowEnergyController::Error pError);
98  void fireReadCharacteristicChanged(const QByteArray& pValue);
99  void fireStatusCharacteristicChanged(const QByteArray& pValue);
100 };
101 
102 } // namespace governikus
governikus::CyberJackWaveDevice::~CyberJackWaveDevice
~CyberJackWaveDevice()
Definition: CyberJackWaveDevice.cpp:42
governikus::CyberJackWaveDevice::fireReadCharacteristicChanged
void fireReadCharacteristicChanged(const QByteArray &pValue)
governikus::CyberJackWaveDevice::fireError
void fireError(QLowEnergyController::Error pError)
CyberJackWaveDevice.h
BluetoothReaderManagerPlugIn_p.h
governikus::CyberJackWaveDevice::CyberJackWaveDevice
CyberJackWaveDevice(const QBluetoothDeviceInfo &pDeviceInfo)
Definition: CyberJackWaveDevice.cpp:25
governikus::NotificationEnabler::enable
bool enable(const QLowEnergyCharacteristic &pCharacteristic)
Definition: NotificationEnabler.cpp:31
governikus::CyberJackWaveDevice::fireDisconnected
void fireDisconnected(const QBluetoothDeviceInfo &pInfo)
governikus::CyberJackWaveDevice::isValid
bool isValid() const
Definition: CyberJackWaveDevice.cpp:52
governikus::CyberJackWaveDevice::fireInitialized
void fireInitialized(const QBluetoothDeviceInfo &pInfo)
governikus::NotificationEnabler::disable
bool disable(const QLowEnergyCharacteristic &pCharacteristic)
Definition: NotificationEnabler.cpp:39
NotificationEnabler.h
governikus
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15
Java_com_governikus_ausweisapp2_AndroidBluetoothReceiver_bluetoothAdapterStateChanged
JNIEXPORT void JNICALL Java_com_governikus_ausweisapp2_AndroidBluetoothReceiver_bluetoothAdapterStateChanged(JNIEnv *env, jobject obj, jint previousState, jint currentState)
Definition: BluetoothReaderManagerPlugIn_p_android.cpp:23
governikus::NotificationEnabler
Definition: NotificationEnabler.h:25
governikus::BluetoothReaderManagerPlugInPrivate::onBluetoothStatusChanged
void onBluetoothStatusChanged(bool pEnabled)
Definition: BluetoothReaderManagerPlugIn_p_android.cpp:75
governikus::AndroidBluetoothAdapter::getDefaultAdapter
static AndroidBluetoothAdapter getDefaultAdapter()
Get the default bluetooth adapter.
Definition: AndroidBluetoothAdapter.cpp:57
governikus::CyberJackWaveDevice::disconnectFromDevice
void disconnectFromDevice()
Disconnect from the device.
Definition: CyberJackWaveDevice.cpp:196
governikus::CyberJackWaveDevice::getName
QString getName() const
Definition: CyberJackWaveDevice.cpp:58
governikus::CyberJackWaveDevice::fireStatusCharacteristicChanged
void fireStatusCharacteristicChanged(const QByteArray &pValue)
governikus::AndroidBluetoothAdapter::getBondedDevices
QVector< QBluetoothDeviceInfo > getBondedDevices() const
Return the set of BluetoothDeviceInfo objects that are bonded (paired) to the local adapter.
Definition: AndroidBluetoothAdapter.cpp:100
governikus::CyberJackWaveDevice::setDeviceInfo
void setDeviceInfo(const QBluetoothDeviceInfo &pInfo)
Definition: CyberJackWaveDevice.cpp:64
BluetoothDebug.h
governikus::BluetoothReaderManagerPlugIn
Definition: BluetoothReaderManagerPlugIn.h:25
governikus::CyberJackWaveDevice
Definition: CyberJackWaveDevice.h:21
AndroidBluetoothAdapter.h
governikus::CyberJackWaveDevice::write
bool write(const QByteArray &pValue)
Definition: CyberJackWaveDevice.cpp:208
governikus::CyberJackWaveDevice::initialize
void initialize()
Connect to the device and initialize.
Definition: CyberJackWaveDevice.cpp:70