Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
DeviceInfo.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020, Cascoda Ltd.
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 are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef POSIX_APP_CHILICTL_COMMON_DEVICEINFO_HPP_
30#define POSIX_APP_CHILICTL_COMMON_DEVICEINFO_HPP_
31
33
34namespace ca {
35
39//class DeviceInfo : private ca_device_info
40
42{
43public:
48 : mBuffer(nullptr)
49 {
50 }
51
56 DeviceInfo(const ca_device_info *aDeviceInfo);
57
62 DeviceInfo(const DeviceInfo &aDeviceInfo);
63
68 DeviceInfo(DeviceInfo &&aDeviceInfo);
69
73 ~DeviceInfo() { delete[] mBuffer; }
74
80 DeviceInfo &operator=(const DeviceInfo &other);
81
88
93 const char *GetExchangeTypeAsString();
94
99
103 const char *GetPath() const { return path; }
104
108 const char *GetDeviceName() const { return device_name; }
109
113 const char *GetAppName() const { return app_name; }
114
118 const char *GetVersion() const { return version; }
119
123 const char *GetSerialNo() const { return serialno; }
124
128 bool IsAvailable() const { return available; }
129
134
135private:
136 char *mBuffer;
137
138 void copy_from(const ca_device_info *aDeviceInfo);
139 void move_from(DeviceInfo &aDeviceInfo);
140};
141
142} /* namespace ca */
143
144#endif /* POSIX_APP_CHILICTL_COMMON_DEVICEINFO_HPP_ */
Various types used by the cascoda posix api.
ca821x_exchange_type
Enumeration for identifying the underlying exchange interface type.
Definition ca821x-types.h:166
C++ wrapper for the C ca_device_info struct, which owns its own memory.
Definition DeviceInfo.hpp:42
const char * GetVersion() const
Definition DeviceInfo.hpp:118
const char * GetDeviceName() const
Definition DeviceInfo.hpp:108
DeviceInfo & operator=(const DeviceInfo &other)
Copy assignment.
Definition DeviceInfo.cpp:51
const char * GetExchangeTypeAsString()
Get the exchange type in a string format.
Definition DeviceInfo.cpp:149
~DeviceInfo()
Destructor to free owned memory.
Definition DeviceInfo.hpp:73
const char * GetAppName() const
Definition DeviceInfo.hpp:113
const char * GetSerialNo() const
Definition DeviceInfo.hpp:123
DeviceInfo()
Default constructor for empty instance.
Definition DeviceInfo.hpp:47
ca821x_exchange_type GetExchangeType() const
Definition DeviceInfo.hpp:98
const char * GetPath() const
Definition DeviceInfo.hpp:103
bool IsAvailable() const
Definition DeviceInfo.hpp:128
bool IsExternalFlashChipAvailable() const
Definition DeviceInfo.hpp:133
Definition Args.cpp:34
Struct for getting info of connected devices (primarily for enumerating them).
Definition ca821x-types.h:224
bool available
Is the device available for use (or not, eg.
Definition ca821x-types.h:233
const char * serialno
Serial number of the device.
Definition ca821x-types.h:230
bool external_flash_available
Does the device have an external flash chip.
Definition ca821x-types.h:232
const char * version
Version string of the device.
Definition ca821x-types.h:229
enum ca821x_exchange_type exchange_type
Exchange type for this device.
Definition ca821x-types.h:225
const char * app_name
Name of the application running on the device, eg 'ot-cli'.
Definition ca821x-types.h:228
const char * device_name
Name of the device, eg 'Chili2'.
Definition ca821x-types.h:227
const char * path
Exchange & system specific 'path', unique to this device.
Definition ca821x-types.h:226