@@ -60,7 +60,93 @@ class BoschSensorInfo
60
60
61
61
~BoschSensorInfo ()
62
62
{
63
- free (info);
63
+ if (info) {
64
+ free (info);
65
+ }
66
+ }
67
+
68
+ BoschSensorInfo (const BoschSensorInfo &other)
69
+ : kernel_version(other.kernel_version),
70
+ user_version (other.user_version),
71
+ rom_version(other.rom_version),
72
+ product_id(other.product_id),
73
+ host_status(other.host_status),
74
+ feat_status(other.feat_status),
75
+ boot_status(other.boot_status),
76
+ sensor_error(other.sensor_error),
77
+ dev(other.dev),
78
+ info(nullptr )
79
+ {
80
+ if (other.info ) {
81
+ info = (struct bhy2_sensor_info *)calloc (BHY2_SENSOR_ID_MAX, sizeof (struct bhy2_sensor_info ));
82
+ for (int i = 0 ; i < BHY2_SENSOR_ID_MAX; ++i) {
83
+ info[i] = other.info [i];
84
+ }
85
+ }
86
+ }
87
+
88
+ BoschSensorInfo &operator =(const BoschSensorInfo &other)
89
+ {
90
+ if (this != &other) {
91
+ if (info) {
92
+ free (info);
93
+ }
94
+ kernel_version = other.kernel_version ;
95
+ user_version = other.user_version ;
96
+ rom_version = other.rom_version ;
97
+ product_id = other.product_id ;
98
+ host_status = other.host_status ;
99
+ feat_status = other.feat_status ;
100
+ boot_status = other.boot_status ;
101
+ sensor_error = other.sensor_error ;
102
+ dev = other.dev ;
103
+ info = nullptr ;
104
+ if (other.info ) {
105
+ info = (struct bhy2_sensor_info *)calloc (BHY2_SENSOR_ID_MAX, sizeof (struct bhy2_sensor_info ));
106
+ for (int i = 0 ; i < BHY2_SENSOR_ID_MAX; ++i) {
107
+ info[i] = other.info [i];
108
+ }
109
+ }
110
+ }
111
+ return *this ;
112
+ }
113
+
114
+ BoschSensorInfo (BoschSensorInfo &&other) noexcept
115
+ : kernel_version(other.kernel_version),
116
+ user_version (other.user_version),
117
+ rom_version(other.rom_version),
118
+ product_id(other.product_id),
119
+ host_status(other.host_status),
120
+ feat_status(other.feat_status),
121
+ boot_status(other.boot_status),
122
+ sensor_error(other.sensor_error),
123
+ dev(other.dev),
124
+ info(other.info)
125
+ {
126
+ other.info = nullptr ;
127
+ other.dev = nullptr ;
128
+ }
129
+
130
+ BoschSensorInfo &operator =(BoschSensorInfo &&other) noexcept
131
+ {
132
+ if (this != &other) {
133
+ if (info) {
134
+ free (info);
135
+ }
136
+ kernel_version = other.kernel_version ;
137
+ user_version = other.user_version ;
138
+ rom_version = other.rom_version ;
139
+ product_id = other.product_id ;
140
+ host_status = other.host_status ;
141
+ feat_status = other.feat_status ;
142
+ boot_status = other.boot_status ;
143
+ sensor_error = other.sensor_error ;
144
+ dev = other.dev ;
145
+ info = other.info ;
146
+ other.info = nullptr ;
147
+ other.dev = nullptr ;
148
+ }
149
+ return *this ;
64
150
}
65
151
66
152
#ifdef ARDUINO
@@ -69,6 +155,9 @@ class BoschSensorInfo
69
155
if (!dev) {
70
156
return ;
71
157
}
158
+ if (!info) {
159
+ return ;
160
+ }
72
161
if (feat_status & BHY2_FEAT_STATUS_OPEN_RTOS_MSK) {
73
162
stream.printf (" Virtual sensor list.\n " );
74
163
stream.printf (" Sensor ID | Sensor Name | ID | Ver | Min rate | Max rate |\n " );
@@ -138,6 +227,9 @@ class BoschSensorInfo
138
227
if (!dev) {
139
228
return ;
140
229
}
230
+ if (!info) {
231
+ return ;
232
+ }
141
233
if (feat_status & BHY2_FEAT_STATUS_OPEN_RTOS_MSK) {
142
234
printf (" Virtual sensor list.\n " );
143
235
printf (" Sensor ID | Sensor Name | ID | Ver | Min rate | Max rate |\n " );
0 commit comments