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
40{
41public:
46 : mBuffer(nullptr)
47 {
48 }
49
54 DeviceInfo(const ca_device_info *aDeviceInfo);
55
60 DeviceInfo(const DeviceInfo &aDeviceInfo);
61
66 DeviceInfo(DeviceInfo &&aDeviceInfo);
67
71 ~DeviceInfo() { delete[] mBuffer; }
72
78 DeviceInfo &operator=(const DeviceInfo &other);
79
86
91 const char *GetExchangeTypeAsString();
92
97
101 const char *GetPath() const { return path; }
102
106 const char *GetDeviceName() const { return device_name; }
107
111 const char *GetAppName() const { return app_name; }
112
116 const char *GetVersion() const { return version; }
117
121 const char *GetSerialNo() const { return serialno; }
122
126 bool IsAvailable() const { return available; }
127
132
133private:
134 char *mBuffer;
135
136 void copy_from(const ca_device_info *aDeviceInfo);
137 void move_from(DeviceInfo &aDeviceInfo);
138};
139
140} /* namespace ca */
141
142#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:40
const char * GetVersion() const
Definition DeviceInfo.hpp:116
const char * GetDeviceName() const
Definition DeviceInfo.hpp:106
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:146
~DeviceInfo()
Destructor to free owned memory.
Definition DeviceInfo.hpp:71
const char * GetAppName() const
Definition DeviceInfo.hpp:111
const char * GetSerialNo() const
Definition DeviceInfo.hpp:121
DeviceInfo()
Default constructor for empty instance.
Definition DeviceInfo.hpp:45
ca821x_exchange_type GetExchangeType() const
Definition DeviceInfo.hpp:96
const char * GetPath() const
Definition DeviceInfo.hpp:101
bool IsAvailable() const
Definition DeviceInfo.hpp:126
bool IsExternalFlashChipAvailable() const
Definition DeviceInfo.hpp:131
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