Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 17 | #include <fcntl.h> |
| 18 | #include <sys/ioctl.h> |
| 19 | #include <unistd.h> |
| 20 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 21 | #include <ChassisIntrusionSensor.hpp> |
| 22 | #include <boost/asio/io_service.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 23 | #include <sdbusplus/asio/object_server.hpp> |
| 24 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 25 | #include <cerrno> |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 26 | #include <chrono> |
| 27 | #include <iostream> |
Patrick Venture | 96e97db | 2019-10-31 13:44:38 -0700 | [diff] [blame] | 28 | #include <memory> |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 29 | #include <string> |
| 30 | #include <thread> |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 31 | #include <utility> |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 32 | |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 33 | extern "C" |
| 34 | { |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 35 | #include <i2c/smbus.h> |
| 36 | #include <linux/i2c-dev.h> |
| 37 | } |
| 38 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 39 | static constexpr bool debug = false; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 40 | |
| 41 | static constexpr unsigned int intrusionSensorPollSec = 1; |
| 42 | |
| 43 | // SMLink Status Register |
| 44 | const static constexpr size_t pchStatusRegIntrusion = 0x04; |
| 45 | |
| 46 | // Status bit field masks |
| 47 | const static constexpr size_t pchRegMaskIntrusion = 0x01; |
| 48 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 49 | void ChassisIntrusionSensor::updateValue(const std::string& newValue) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 50 | { |
Josh Lehan | 833661a | 2020-03-04 17:35:41 -0800 | [diff] [blame] | 51 | // Take no action if value already equal |
| 52 | // Same semantics as Sensor::updateValue(const double&) |
| 53 | if (newValue == mValue) |
| 54 | { |
| 55 | return; |
| 56 | } |
| 57 | |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 58 | // indicate that it is internal set call |
| 59 | mInternalSet = true; |
| 60 | mIface->set_property("Status", newValue); |
Richard Marian Thomaiyar | af6b87c | 2019-04-03 23:54:28 +0530 | [diff] [blame] | 61 | mInternalSet = false; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 62 | |
| 63 | mValue = newValue; |
| 64 | |
| 65 | if (mOldValue == "Normal" && mValue != "Normal") |
| 66 | { |
| 67 | std::cerr << "save to SEL for intrusion assert event \n"; |
| 68 | // TODO: call add SEL log API, depends on patch #13956 |
| 69 | mOldValue = mValue; |
| 70 | } |
| 71 | else if (mOldValue != "Normal" && mValue == "Normal") |
| 72 | { |
| 73 | std::cerr << "save to SEL for intrusion de-assert event \n"; |
| 74 | // TODO: call add SEL log API, depends on patch #13956 |
| 75 | mOldValue = mValue; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | int ChassisIntrusionSensor::i2cReadFromPch(int busId, int slaveAddr) |
| 80 | { |
| 81 | std::string i2cBus = "/dev/i2c-" + std::to_string(busId); |
| 82 | |
Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 83 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 84 | int fd = open(i2cBus.c_str(), O_RDWR | O_CLOEXEC); |
| 85 | if (fd < 0) |
| 86 | { |
| 87 | std::cerr << "unable to open i2c device \n"; |
| 88 | return -1; |
| 89 | } |
Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 90 | |
| 91 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 92 | if (ioctl(fd, I2C_SLAVE_FORCE, slaveAddr) < 0) |
| 93 | { |
| 94 | std::cerr << "unable to set device address\n"; |
| 95 | close(fd); |
| 96 | return -1; |
| 97 | } |
| 98 | |
| 99 | unsigned long funcs = 0; |
Ed Tanous | 99c4409 | 2022-01-14 09:59:09 -0800 | [diff] [blame] | 100 | |
| 101 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 102 | if (ioctl(fd, I2C_FUNCS, &funcs) < 0) |
| 103 | { |
| 104 | std::cerr << "not support I2C_FUNCS \n"; |
| 105 | close(fd); |
| 106 | return -1; |
| 107 | } |
| 108 | |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 109 | if ((funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA) == 0U) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 110 | { |
| 111 | std::cerr << "not support I2C_FUNC_SMBUS_READ_BYTE_DATA \n"; |
| 112 | close(fd); |
| 113 | return -1; |
| 114 | } |
| 115 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 116 | int32_t statusMask = pchRegMaskIntrusion; |
| 117 | int32_t statusReg = pchStatusRegIntrusion; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 118 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 119 | int32_t statusValue = i2c_smbus_read_byte_data(fd, statusReg); |
| 120 | if (debug) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 121 | { |
| 122 | std::cout << "\nRead bus " << busId << " addr " << slaveAddr |
| 123 | << ", value = " << statusValue << "\n"; |
| 124 | } |
| 125 | |
| 126 | close(fd); |
| 127 | |
| 128 | if (statusValue < 0) |
| 129 | { |
| 130 | std::cerr << "i2c_smbus_read_byte_data failed \n"; |
| 131 | return -1; |
| 132 | } |
| 133 | |
| 134 | // Get status value with mask |
| 135 | int newValue = statusValue & statusMask; |
| 136 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 137 | if (debug) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 138 | { |
| 139 | std::cout << "statusValue is " << statusValue << "\n"; |
| 140 | std::cout << "Intrusion sensor value is " << newValue << "\n"; |
| 141 | } |
| 142 | |
| 143 | return newValue; |
| 144 | } |
| 145 | |
| 146 | void ChassisIntrusionSensor::pollSensorStatusByPch() |
| 147 | { |
| 148 | // setting a new experation implicitly cancels any pending async wait |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 149 | mPollTimer.expires_from_now(std::chrono::seconds(intrusionSensorPollSec)); |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 150 | |
| 151 | mPollTimer.async_wait([&](const boost::system::error_code& ec) { |
| 152 | // case of timer expired |
| 153 | if (!ec) |
| 154 | { |
| 155 | int statusValue = i2cReadFromPch(mBusId, mSlaveAddr); |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 156 | std::string newValue = |
| 157 | statusValue != 0 ? "HardwareIntrusion" : "Normal"; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 158 | |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 159 | if (newValue != "unknown" && mValue != newValue) |
| 160 | { |
| 161 | std::cout << "update value from " << mValue << " to " |
| 162 | << newValue << "\n"; |
| 163 | updateValue(newValue); |
| 164 | } |
| 165 | |
| 166 | // trigger next polling |
| 167 | pollSensorStatusByPch(); |
| 168 | } |
| 169 | // case of being canceled |
| 170 | else if (ec == boost::asio::error::operation_aborted) |
| 171 | { |
| 172 | std::cerr << "Timer of intrusion sensor is cancelled. Return \n"; |
| 173 | return; |
| 174 | } |
| 175 | }); |
| 176 | } |
| 177 | |
| 178 | void ChassisIntrusionSensor::readGpio() |
| 179 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 180 | mGpioLine.event_read(); |
| 181 | auto value = mGpioLine.get_value(); |
| 182 | |
| 183 | // set string defined in chassis redfish schema |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 184 | std::string newValue = value != 0 ? "HardwareIntrusion" : "Normal"; |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 185 | |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 186 | if (debug) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 187 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 188 | std::cout << "\nGPIO value is " << value << "\n"; |
| 189 | std::cout << "Intrusion sensor value is " << newValue << "\n"; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 190 | } |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 191 | |
| 192 | if (newValue != "unknown" && mValue != newValue) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 193 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 194 | std::cout << "update value from " << mValue << " to " << newValue |
| 195 | << "\n"; |
| 196 | updateValue(newValue); |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | |
| 200 | void ChassisIntrusionSensor::pollSensorStatusByGpio(void) |
| 201 | { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 202 | mGpioFd.async_wait(boost::asio::posix::stream_descriptor::wait_read, |
| 203 | [this](const boost::system::error_code& ec) { |
| 204 | if (ec == boost::system::errc::bad_file_descriptor) |
| 205 | { |
| 206 | return; // we're being destroyed |
| 207 | } |
| 208 | if (ec) |
| 209 | { |
| 210 | std::cerr << "Error on GPIO based intrusion sensor wait event\n"; |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | readGpio(); |
| 215 | } |
| 216 | pollSensorStatusByGpio(); |
| 217 | }); |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 218 | } |
| 219 | |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 220 | void ChassisIntrusionSensor::initGpioDeviceFile() |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 221 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 222 | mGpioLine = gpiod::find_line(mPinName); |
| 223 | if (!mGpioLine) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 224 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 225 | std::cerr << "ChassisIntrusionSensor error finding gpio pin name: " |
| 226 | << mPinName << "\n"; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 227 | return; |
| 228 | } |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 229 | |
| 230 | try |
| 231 | { |
| 232 | |
| 233 | mGpioLine.request( |
| 234 | {"ChassisIntrusionSensor", gpiod::line_request::EVENT_BOTH_EDGES, |
| 235 | mGpioInverted ? gpiod::line_request::FLAG_ACTIVE_LOW : 0}); |
| 236 | |
| 237 | // set string defined in chassis redfish schema |
| 238 | auto value = mGpioLine.get_value(); |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 239 | std::string newValue = value != 0 ? "HardwareIntrusion" : "Normal"; |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 240 | updateValue(newValue); |
| 241 | |
| 242 | auto gpioLineFd = mGpioLine.event_get_fd(); |
| 243 | if (gpioLineFd < 0) |
| 244 | { |
| 245 | std::cerr << "ChassisIntrusionSensor failed to get " << mPinName |
| 246 | << " fd\n"; |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | mGpioFd.assign(gpioLineFd); |
| 251 | } |
Patrick Williams | 26601e8 | 2021-10-06 12:43:25 -0500 | [diff] [blame] | 252 | catch (const std::system_error&) |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 253 | { |
| 254 | std::cerr << "ChassisInrtusionSensor error requesting gpio pin name: " |
| 255 | << mPinName << "\n"; |
| 256 | return; |
| 257 | } |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | int ChassisIntrusionSensor::setSensorValue(const std::string& req, |
| 261 | std::string& propertyValue) |
| 262 | { |
Richard Marian Thomaiyar | af6b87c | 2019-04-03 23:54:28 +0530 | [diff] [blame] | 263 | if (!mInternalSet) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 264 | { |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 265 | propertyValue = req; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 266 | mOverridenState = true; |
| 267 | } |
Richard Marian Thomaiyar | af6b87c | 2019-04-03 23:54:28 +0530 | [diff] [blame] | 268 | else if (!mOverridenState) |
| 269 | { |
| 270 | propertyValue = req; |
| 271 | } |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 272 | return 1; |
| 273 | } |
| 274 | |
| 275 | void ChassisIntrusionSensor::start(IntrusionSensorType type, int busId, |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 276 | int slaveAddr, bool gpioInverted) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 277 | { |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 278 | if (debug) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 279 | { |
| 280 | std::cerr << "enter ChassisIntrusionSensor::start, type = " << type |
| 281 | << "\n"; |
| 282 | if (type == IntrusionSensorType::pch) |
| 283 | { |
| 284 | std::cerr << "busId = " << busId << ", slaveAddr = " << slaveAddr |
| 285 | << "\n"; |
| 286 | } |
| 287 | else if (type == IntrusionSensorType::gpio) |
| 288 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 289 | std::cerr << "gpio pinName = " << mPinName |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 290 | << ", gpioInverted = " << gpioInverted << "\n"; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | if ((type == IntrusionSensorType::pch && busId == mBusId && |
| 295 | slaveAddr == mSlaveAddr) || |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 296 | (type == IntrusionSensorType::gpio && gpioInverted == mGpioInverted && |
| 297 | mInitialized)) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 298 | { |
| 299 | return; |
| 300 | } |
| 301 | |
| 302 | mType = type; |
| 303 | mBusId = busId; |
| 304 | mSlaveAddr = slaveAddr; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 305 | mGpioInverted = gpioInverted; |
| 306 | |
| 307 | if ((mType == IntrusionSensorType::pch && mBusId > 0 && mSlaveAddr > 0) || |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 308 | (mType == IntrusionSensorType::gpio)) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 309 | { |
| 310 | // initialize first if not initialized before |
| 311 | if (!mInitialized) |
| 312 | { |
| 313 | mIface->register_property( |
| 314 | "Status", mValue, |
| 315 | [&](const std::string& req, std::string& propertyValue) { |
Ed Tanous | bb67932 | 2022-05-16 16:10:00 -0700 | [diff] [blame] | 316 | return setSensorValue(req, propertyValue); |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 317 | }); |
| 318 | mIface->initialize(); |
| 319 | |
| 320 | if (mType == IntrusionSensorType::gpio) |
| 321 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 322 | initGpioDeviceFile(); |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | mInitialized = true; |
| 326 | } |
| 327 | |
| 328 | // start polling value |
| 329 | if (mType == IntrusionSensorType::pch) |
| 330 | { |
| 331 | pollSensorStatusByPch(); |
| 332 | } |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 333 | else if (mType == IntrusionSensorType::gpio && mGpioLine) |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 334 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 335 | std::cerr << "Start polling intrusion sensors\n"; |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 336 | pollSensorStatusByGpio(); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // invalid para, release resource |
| 341 | else |
| 342 | { |
| 343 | if (mInitialized) |
| 344 | { |
| 345 | if (mType == IntrusionSensorType::pch) |
| 346 | { |
| 347 | mPollTimer.cancel(); |
| 348 | } |
| 349 | else if (mType == IntrusionSensorType::gpio) |
| 350 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 351 | mGpioFd.close(); |
| 352 | if (mGpioLine) |
| 353 | { |
| 354 | mGpioLine.release(); |
| 355 | } |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 356 | } |
| 357 | mInitialized = false; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | ChassisIntrusionSensor::ChassisIntrusionSensor( |
| 363 | boost::asio::io_service& io, |
| 364 | std::shared_ptr<sdbusplus::asio::dbus_interface> iface) : |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 365 | mIface(std::move(iface)), |
Ed Tanous | b429f31 | 2022-06-27 16:09:53 -0700 | [diff] [blame] | 366 | mValue("unknown"), mOldValue("unknown"), mPollTimer(io), mGpioFd(io) |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 367 | {} |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 368 | |
| 369 | ChassisIntrusionSensor::~ChassisIntrusionSensor() |
| 370 | { |
| 371 | if (mType == IntrusionSensorType::pch) |
| 372 | { |
| 373 | mPollTimer.cancel(); |
| 374 | } |
| 375 | else if (mType == IntrusionSensorType::gpio) |
| 376 | { |
ZhikuiRen | ba8a8bf | 2020-01-09 15:55:43 -0800 | [diff] [blame] | 377 | mGpioFd.close(); |
| 378 | if (mGpioLine) |
| 379 | { |
| 380 | mGpioLine.release(); |
| 381 | } |
Qiang XU | e28d1fa | 2019-02-27 13:50:56 +0800 | [diff] [blame] | 382 | } |
| 383 | } |