gForceSDK
Device.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, OYMotion Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28  * DAMAGE.
29  *
30  */
38 #pragma once
39 
40 #include "gfTypes.h"
41 
42 namespace gf
43 {
44  class DeviceListener;
45  class DeviceSetting;
46 
53  class Device
54  {
55  public:
58  virtual GF_UINT8 getAddrType() const = 0;
59 
64  virtual tstring getAddress() const = 0;
65 
69  virtual tstring getName() const = 0;
70 
76  virtual GF_UINT getRssi() const = 0;
77 
84  virtual GF_RET_CODE identify(int msec = 1000) = 0;
85 
88  virtual DeviceConnectionStatus getConnectionStatus() const = 0;
89 
93  virtual GF_RET_CODE setAlias(tstring alias) = 0;
94 
99  virtual tstring getAlias() const = 0;
100 
114  virtual GF_RET_CODE connect(bool directConn = true) = 0;
115 
128  virtual GF_RET_CODE disconnect() = 0;
129 
142  virtual GF_RET_CODE cancelConnect() = 0;
143 
144  // externsion for new protocol
145 
153 
154  protected:
157  virtual ~Device() {}
158  };
159 
160 } // namespace gf
virtual GF_RET_CODE identify(int msec=1000)=0
Identifies a physical device using vibration or light, if the device supports.
virtual GF_RET_CODE cancelConnect()=0
Cancels connecting to the device.
virtual GF_UINT8 getAddrType() const =0
Gets the device address type.
DeviceConnectionStatus
Possible gForce device connection status.
Definition: gfTypes.h:205
virtual GF_RET_CODE connect(bool directConn=true)=0
Connects to the device.
unsigned int GF_UINT
type definition
Definition: gfTypes.h:58
virtual tstring getAlias() const =0
Get the alias of the device set before.
virtual GF_RET_CODE setAlias(tstring alias)=0
Sets an alias to the devie for identification.
The abstract class of a gForce device.
Definition: Device.h:53
std::string tstring
std::string type definition for ANSI/UNICODE convenience
Definition: gfTypes.h:98
virtual GF_RET_CODE disconnect()=0
Disconnects from the device.
virtual gfsPtr< DeviceSetting > getDeviceSetting()=0
Get DeviceSetting of a device.
The namespace in which all of the gForceSDK project definitions are contained.
Definition: Device.h:42
virtual ~Device()
Virtual deconstructor.
Definition: Device.h:157
virtual GF_UINT getRssi() const =0
Gets the device RSSI value.
std::shared_ptr< T > gfsPtr
The strong pointer.
Definition: gfTypes.h:113
virtual tstring getName() const =0
Gets the device name.
virtual tstring getAddress() const =0
Gets the string type of device address.
GF_RET_CODE
Defines possible return values of methods.
Definition: gfTypes.h:138
virtual DeviceConnectionStatus getConnectionStatus() const =0
Retrieves the connection status of the device.
The abstract of the device setting handler of a gForce device.
Definition: DeviceSetting.h:60
The basic type definitions using in gForceSDK.
unsigned char GF_UINT8
type definition
Definition: gfTypes.h:65