Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MaximInterface
SensorNode.hpp@0:33d4e66780c0, 2017-02-24 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Fri Feb 24 11:23:12 2017 -0600
- Revision:
- 0:33d4e66780c0
- Child:
- 13:6a6225690c2e
Initial commit.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IanBenzMaxim | 0:33d4e66780c0 | 1 | /******************************************************************************* |
| IanBenzMaxim | 0:33d4e66780c0 | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
| IanBenzMaxim | 0:33d4e66780c0 | 3 | * |
| IanBenzMaxim | 0:33d4e66780c0 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| IanBenzMaxim | 0:33d4e66780c0 | 5 | * copy of this software and associated documentation files (the "Software"), |
| IanBenzMaxim | 0:33d4e66780c0 | 6 | * to deal in the Software without restriction, including without limitation |
| IanBenzMaxim | 0:33d4e66780c0 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| IanBenzMaxim | 0:33d4e66780c0 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| IanBenzMaxim | 0:33d4e66780c0 | 9 | * Software is furnished to do so, subject to the following conditions: |
| IanBenzMaxim | 0:33d4e66780c0 | 10 | * |
| IanBenzMaxim | 0:33d4e66780c0 | 11 | * The above copyright notice and this permission notice shall be included |
| IanBenzMaxim | 0:33d4e66780c0 | 12 | * in all copies or substantial portions of the Software. |
| IanBenzMaxim | 0:33d4e66780c0 | 13 | * |
| IanBenzMaxim | 0:33d4e66780c0 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| IanBenzMaxim | 0:33d4e66780c0 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| IanBenzMaxim | 0:33d4e66780c0 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| IanBenzMaxim | 0:33d4e66780c0 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| IanBenzMaxim | 0:33d4e66780c0 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| IanBenzMaxim | 0:33d4e66780c0 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| IanBenzMaxim | 0:33d4e66780c0 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| IanBenzMaxim | 0:33d4e66780c0 | 21 | * |
| IanBenzMaxim | 0:33d4e66780c0 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
| IanBenzMaxim | 0:33d4e66780c0 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| IanBenzMaxim | 0:33d4e66780c0 | 24 | * Products, Inc. Branding Policy. |
| IanBenzMaxim | 0:33d4e66780c0 | 25 | * |
| IanBenzMaxim | 0:33d4e66780c0 | 26 | * The mere transfer of this software does not imply any licenses |
| IanBenzMaxim | 0:33d4e66780c0 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
| IanBenzMaxim | 0:33d4e66780c0 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
| IanBenzMaxim | 0:33d4e66780c0 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| IanBenzMaxim | 0:33d4e66780c0 | 30 | * ownership rights. |
| IanBenzMaxim | 0:33d4e66780c0 | 31 | *******************************************************************************/ |
| IanBenzMaxim | 0:33d4e66780c0 | 32 | |
| IanBenzMaxim | 0:33d4e66780c0 | 33 | #ifndef SENSORNODE_HPP |
| IanBenzMaxim | 0:33d4e66780c0 | 34 | #define SENSORNODE_HPP |
| IanBenzMaxim | 0:33d4e66780c0 | 35 | |
| IanBenzMaxim | 0:33d4e66780c0 | 36 | #include <stdint.h> |
| IanBenzMaxim | 0:33d4e66780c0 | 37 | #include <Callback.h> |
| IanBenzMaxim | 0:33d4e66780c0 | 38 | #include "DS28C36.hpp" |
| IanBenzMaxim | 0:33d4e66780c0 | 39 | |
| IanBenzMaxim | 0:33d4e66780c0 | 40 | namespace mbed { class I2C; } |
| IanBenzMaxim | 0:33d4e66780c0 | 41 | class DS2476; |
| IanBenzMaxim | 0:33d4e66780c0 | 42 | |
| IanBenzMaxim | 0:33d4e66780c0 | 43 | /// Interface to the authenticated sensor node peripheral board. |
| IanBenzMaxim | 0:33d4e66780c0 | 44 | class SensorNode |
| IanBenzMaxim | 0:33d4e66780c0 | 45 | { |
| IanBenzMaxim | 0:33d4e66780c0 | 46 | public: |
| IanBenzMaxim | 0:33d4e66780c0 | 47 | /// Prints a null-terminated char string. |
| IanBenzMaxim | 0:33d4e66780c0 | 48 | typedef mbed::Callback<void(const char *)> PrintHandler; |
| IanBenzMaxim | 0:33d4e66780c0 | 49 | |
| IanBenzMaxim | 0:33d4e66780c0 | 50 | /// Style of temperature to measure. |
| IanBenzMaxim | 0:33d4e66780c0 | 51 | enum TempStyle |
| IanBenzMaxim | 0:33d4e66780c0 | 52 | { |
| IanBenzMaxim | 0:33d4e66780c0 | 53 | AmbientTemp, |
| IanBenzMaxim | 0:33d4e66780c0 | 54 | ObjectTemp |
| IanBenzMaxim | 0:33d4e66780c0 | 55 | }; |
| IanBenzMaxim | 0:33d4e66780c0 | 56 | |
| IanBenzMaxim | 0:33d4e66780c0 | 57 | /// @param i2c I2C bus connected to the sensor node. Communicates with DS28C36 and MLX90614. |
| IanBenzMaxim | 0:33d4e66780c0 | 58 | /// @param ds2476 Coprocessor used for authentication computations. |
| IanBenzMaxim | 0:33d4e66780c0 | 59 | SensorNode(mbed::I2C & i2c, DS2476 & ds2476); |
| IanBenzMaxim | 0:33d4e66780c0 | 60 | |
| IanBenzMaxim | 0:33d4e66780c0 | 61 | /// Detects if a potential sensor node is connected. |
| IanBenzMaxim | 0:33d4e66780c0 | 62 | /// @returns True if something was detected. |
| IanBenzMaxim | 0:33d4e66780c0 | 63 | bool detect(); |
| IanBenzMaxim | 0:33d4e66780c0 | 64 | |
| IanBenzMaxim | 0:33d4e66780c0 | 65 | /// Checks if the sensor node is authentic. |
| IanBenzMaxim | 0:33d4e66780c0 | 66 | /// @returns True if the sensor node passed the authentication check. |
| IanBenzMaxim | 0:33d4e66780c0 | 67 | bool authenticate(); |
| IanBenzMaxim | 0:33d4e66780c0 | 68 | |
| IanBenzMaxim | 0:33d4e66780c0 | 69 | /// Checks if the laser is enabled. |
| IanBenzMaxim | 0:33d4e66780c0 | 70 | /// @param[out] enabled Set to true if the laser is enabled. Only valid if check successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 71 | /// @returns True if check was successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 72 | bool getLaserEnabled(bool & enabled); |
| IanBenzMaxim | 0:33d4e66780c0 | 73 | |
| IanBenzMaxim | 0:33d4e66780c0 | 74 | /// Enable or disable the laser. |
| IanBenzMaxim | 0:33d4e66780c0 | 75 | /// @param enabled True to enable the laser or false to disable. |
| IanBenzMaxim | 0:33d4e66780c0 | 76 | /// @param print Optional callback for displaying informational messages to the user. |
| IanBenzMaxim | 0:33d4e66780c0 | 77 | /// @returns True if the operation was successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 78 | bool setLaserEnabled(bool enabled, const PrintHandler & print = PrintHandler()); |
| IanBenzMaxim | 0:33d4e66780c0 | 79 | |
| IanBenzMaxim | 0:33d4e66780c0 | 80 | /// Get a temperature measurement from the MLX90614. |
| IanBenzMaxim | 0:33d4e66780c0 | 81 | /// @param style Temperature style to read. |
| IanBenzMaxim | 0:33d4e66780c0 | 82 | /// @param[out] temp Temperature in Celsius. Only valid if operation successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 83 | /// @returns True if the operation was successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 84 | bool readTemp(TempStyle style, double & temp); |
| IanBenzMaxim | 0:33d4e66780c0 | 85 | |
| IanBenzMaxim | 0:33d4e66780c0 | 86 | /// Checks if the sensor node is provisioned. |
| IanBenzMaxim | 0:33d4e66780c0 | 87 | /// @param[out] provisioned True if provisioned. Only valid if check successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 88 | /// @returns True if the check was successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 89 | bool getProvisioned(bool & provisioned); |
| IanBenzMaxim | 0:33d4e66780c0 | 90 | |
| IanBenzMaxim | 0:33d4e66780c0 | 91 | /// Provision the sensor node. |
| IanBenzMaxim | 0:33d4e66780c0 | 92 | /// @returns True if the operation was successful. |
| IanBenzMaxim | 0:33d4e66780c0 | 93 | bool provision(); |
| IanBenzMaxim | 0:33d4e66780c0 | 94 | |
| IanBenzMaxim | 0:33d4e66780c0 | 95 | private: |
| IanBenzMaxim | 0:33d4e66780c0 | 96 | mbed::I2C & i2c; |
| IanBenzMaxim | 0:33d4e66780c0 | 97 | DS28C36 ds28c36; |
| IanBenzMaxim | 0:33d4e66780c0 | 98 | DS2476 & ds2476; |
| IanBenzMaxim | 0:33d4e66780c0 | 99 | }; |
| IanBenzMaxim | 0:33d4e66780c0 | 100 | |
| IanBenzMaxim | 0:33d4e66780c0 | 101 | #endif |