I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X

Dependencies:   mbed FXOS8700CQ mbed-rtos WNCInterface M2XStreamClient-JMF jsonlite

Committer:
ng977t
Date:
Thu Apr 18 22:58:31 2019 +0000
Revision:
13:99c72ab600c9
Parent:
4:08979e323c6e
I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jk431j 4:08979e323c6e 1 /* ===================================================================
jk431j 4:08979e323c6e 2 Copyright © 2016, AVNET Inc.
jk431j 4:08979e323c6e 3
jk431j 4:08979e323c6e 4 Licensed under the Apache License, Version 2.0 (the "License");
jk431j 4:08979e323c6e 5 you may not use this file except in compliance with the License.
jk431j 4:08979e323c6e 6 You may obtain a copy of the License at
jk431j 4:08979e323c6e 7
jk431j 4:08979e323c6e 8 http://www.apache.org/licenses/LICENSE-2.0
jk431j 4:08979e323c6e 9
jk431j 4:08979e323c6e 10 Unless required by applicable law or agreed to in writing,
jk431j 4:08979e323c6e 11 software distributed under the License is distributed on an
jk431j 4:08979e323c6e 12 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
jk431j 4:08979e323c6e 13 either express or implied. See the License for the specific
jk431j 4:08979e323c6e 14 language governing permissions and limitations under the License.
jk431j 4:08979e323c6e 15
jk431j 4:08979e323c6e 16 ======================================================================== */
jk431j 4:08979e323c6e 17
jk431j 4:08979e323c6e 18 #ifndef HTS221_H_
jk431j 4:08979e323c6e 19 #define HTS221_H_
jk431j 4:08979e323c6e 20
jk431j 4:08979e323c6e 21 class HTS221 {
jk431j 4:08979e323c6e 22 public:
jk431j 4:08979e323c6e 23 HTS221(void);
jk431j 4:08979e323c6e 24 int begin(void);
jk431j 4:08979e323c6e 25 int activate(void);
jk431j 4:08979e323c6e 26 int deactivate(void);
jk431j 4:08979e323c6e 27
jk431j 4:08979e323c6e 28 int bduActivate(void);
jk431j 4:08979e323c6e 29 int bduDeactivate(void);
jk431j 4:08979e323c6e 30
jk431j 4:08979e323c6e 31 int readHumidity(void);
jk431j 4:08979e323c6e 32 double readTemperature(void);
jk431j 4:08979e323c6e 33 private:
jk431j 4:08979e323c6e 34 int storeCalibration(void);
jk431j 4:08979e323c6e 35 unsigned char _h0_rH, _h1_rH;
jk431j 4:08979e323c6e 36 unsigned int _T0_degC, _T1_degC;
jk431j 4:08979e323c6e 37 unsigned int _H0_T0, _H1_T0;
jk431j 4:08979e323c6e 38 unsigned int _T0_OUT, _T1_OUT;
jk431j 4:08979e323c6e 39 double _temperature;
jk431j 4:08979e323c6e 40 int _humidity;
jk431j 4:08979e323c6e 41 unsigned char _address;
jk431j 4:08979e323c6e 42
jk431j 4:08979e323c6e 43 unsigned char readRegister(unsigned char slaveAddress, unsigned char regToRead);
jk431j 4:08979e323c6e 44 int writeRegister(unsigned char slaveAddress, unsigned char regToWrite, unsigned char dataToWrite);
jk431j 4:08979e323c6e 45 };
jk431j 4:08979e323c6e 46
jk431j 4:08979e323c6e 47 #define HTS221_ADDRESS 0xBF
jk431j 4:08979e323c6e 48
jk431j 4:08979e323c6e 49 //Define a few of the registers that we will be accessing on the HTS221
jk431j 4:08979e323c6e 50 #define WHO_AM_I 0x0F
jk431j 4:08979e323c6e 51 #define WHO_AM_I_RETURN 0xBC //This read-only register contains the device identifier, set to BCh
jk431j 4:08979e323c6e 52
jk431j 4:08979e323c6e 53 #define AVERAGE_REG 0x10 // To configure humidity/temperature average.
jk431j 4:08979e323c6e 54 #define AVERAGE_DEFAULT 0x1B
jk431j 4:08979e323c6e 55
jk431j 4:08979e323c6e 56 /*
jk431j 4:08979e323c6e 57 * [7] PD: power down control
jk431j 4:08979e323c6e 58 * (0: power-down mode; 1: active mode)
jk431j 4:08979e323c6e 59 *
jk431j 4:08979e323c6e 60 * [6:3] Reserved
jk431j 4:08979e323c6e 61 *
jk431j 4:08979e323c6e 62 * [2] BDU: block data update
jk431j 4:08979e323c6e 63 * (0: continuous update; 1: output registers not updated until MSB and LSB reading)
jk431j 4:08979e323c6e 64 The BDU bit is used to inhibit the output register update between the reading of the upper
jk431j 4:08979e323c6e 65 and lower register parts. In default mode (BDU = ?0?), the lower and upper register parts are
jk431j 4:08979e323c6e 66 updated continuously. If it is not certain whether the read will be faster than output data rate,
jk431j 4:08979e323c6e 67 it is recommended to set the BDU bit to ?1?. In this way, after the reading of the lower (upper)
jk431j 4:08979e323c6e 68 register part, the content of that output register is not updated until the upper (lower) part is
jk431j 4:08979e323c6e 69 read also.
jk431j 4:08979e323c6e 70 *
jk431j 4:08979e323c6e 71 * [1:0] ODR1, ODR0: output data rate selection (see table 17)
jk431j 4:08979e323c6e 72 */
jk431j 4:08979e323c6e 73 #define CTRL_REG1 0x20
jk431j 4:08979e323c6e 74 #define POWER_UP 0x80
jk431j 4:08979e323c6e 75 #define BDU_SET 0x4
jk431j 4:08979e323c6e 76 #define ODR0_SET 0x1 // setting sensor reading period 1Hz
jk431j 4:08979e323c6e 77
jk431j 4:08979e323c6e 78 #define CTRL_REG2 0x21
jk431j 4:08979e323c6e 79 #define CTRL_REG3 0x22
jk431j 4:08979e323c6e 80 #define REG_DEFAULT 0x00
jk431j 4:08979e323c6e 81
jk431j 4:08979e323c6e 82 #define STATUS_REG 0x27
jk431j 4:08979e323c6e 83 #define TEMPERATURE_READY 0x1
jk431j 4:08979e323c6e 84 #define HUMIDITY_READY 0x2
jk431j 4:08979e323c6e 85
jk431j 4:08979e323c6e 86 #define HUMIDITY_L_REG 0x28
jk431j 4:08979e323c6e 87 #define HUMIDITY_H_REG 0x29
jk431j 4:08979e323c6e 88 #define TEMP_L_REG 0x2A
jk431j 4:08979e323c6e 89 #define TEMP_H_REG 0x2B
jk431j 4:08979e323c6e 90 /*
jk431j 4:08979e323c6e 91 * calibration registry should be read for temperature and humidity calculation.
jk431j 4:08979e323c6e 92 * Before the first calculation of temperature and humidity,
jk431j 4:08979e323c6e 93 * the master reads out the calibration coefficients.
jk431j 4:08979e323c6e 94 * will do at init phase
jk431j 4:08979e323c6e 95 */
jk431j 4:08979e323c6e 96 #define CALIB_START 0x30
jk431j 4:08979e323c6e 97 #define CALIB_END 0x3F
jk431j 4:08979e323c6e 98 /*
jk431j 4:08979e323c6e 99 #define CALIB_T0_DEGC_X8 0x32
jk431j 4:08979e323c6e 100 #define CALIB_T1_DEGC_X8 0x33
jk431j 4:08979e323c6e 101 #define CALIB_T1_T0_MSB 0x35
jk431j 4:08979e323c6e 102 #define CALIB_T0_OUT_L 0x3C
jk431j 4:08979e323c6e 103 #define CALIB_T0_OUT_H 0x3D
jk431j 4:08979e323c6e 104 #define CALIB_T1_OUT_L 0x3E
jk431j 4:08979e323c6e 105 #define CALIB_T1_OUT_H 0x3F
jk431j 4:08979e323c6e 106 */
jk431j 4:08979e323c6e 107
jk431j 4:08979e323c6e 108 #endif