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: MQTT NetworkSocketAPI X_NUCLEO_IKS01A2 mbed
Fork of Nucleo_NbIotBG96_A2_cloud_IBM by
Diff: main.cpp
- Revision:
- 1:a622606a49fd
- Parent:
- 0:ae6c6727b545
- Child:
- 2:b72797c38464
--- a/main.cpp Fri Nov 17 17:23:30 2017 +0100
+++ b/main.cpp Fri Nov 17 17:37:18 2017 +0100
@@ -96,21 +96,15 @@
MQTTString TopicName={TOPIC};
MQTT::MessageData MsgData(TopicName, message);
-
-//#if SENSOR_ENABLED
- //#if SENSOR_MODEL == 2
-
- /* Instantiate the expansion board */
- static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance(D14, D15, D4, D5);
+/* Instantiate the expansion board */
+static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance(D14, D15, D4, D5);
- /* Retrieve the composing elements of the expansion board */
- static LSM303AGRMagSensor *magnetometer = mems_expansion_board->magnetometer;
- static HTS221Sensor *hum_temp = mems_expansion_board->ht_sensor;
- static LPS22HBSensor *press_temp = mems_expansion_board->pt_sensor;
- static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro;
- static LSM303AGRAccSensor *accelerometer = mems_expansion_board->accelerometer;
- //#endif
-//#endif
+/* Retrieve the composing elements of the expansion board */
+static LSM303AGRMagSensor *magnetometer = mems_expansion_board->magnetometer;
+static HTS221Sensor *hum_temp = mems_expansion_board->ht_sensor;
+static LPS22HBSensor *press_temp = mems_expansion_board->pt_sensor;
+static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro;
+static LSM303AGRAccSensor *accelerometer = mems_expansion_board->accelerometer;
void subscribe_cb(MQTT::MessageData & msgMQTT) {
char msg[MQTT_MAX_PAYLOAD_SIZE];
@@ -228,21 +222,14 @@
float temp, temp1, temp2, press, hum;
#if SENSOR_ENABLED
- pc.printf("reading sensors...");
- #if SENSOR_MODEL == 1
- temp_sensor1->GetTemperature(&temp);
- pressure_sensor->GetPressure(&press);
- humidity_sensor->GetHumidity(&hum);
- #endif
-
- #if SENSOR_MODEL == 2
+ pc.printf("A02 reading sensors...");
+
hum_temp->get_temperature(&temp1);
hum_temp->get_humidity(&hum);
press_temp->get_temperature(&temp2);
press_temp->get_pressure(&press);
temp = (temp1+temp2)/2;
- #endif
pc.printf(" DONE\r\n");
#else
@@ -297,7 +284,7 @@
//wait(0.5);
pc.printf("\r\n*************************************************");
wait( 0.1 );
- pc.printf("\r\nAvnet Silica NbIotBG96 mbed-os application\r\n");
+ pc.printf("\r\nAvnet Silica NbIotBG96 A02 mbed-os application\r\n");
wait( 0.1 );
pc.printf("MBED online version %s\r\n", FW_REV);
wait( 0.1 );
@@ -305,25 +292,13 @@
//wait( 0.1 );
#if SENSOR_ENABLED
- #if SENSOR_MODEL == 1
- DevI2C *i2c = new DevI2C(I2C_SDA, I2C_SCL);
- i2c->frequency(400000);
-
- X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(i2c);
- pressure_sensor = mems_expansion_board->pt_sensor;
- temp_sensor1 = mems_expansion_board->ht_sensor;
- humidity_sensor = mems_expansion_board->ht_sensor;
- #endif
-
- #if SENSOR_MODEL == 2
- /* Enable all sensors */
- hum_temp->enable();
- press_temp->enable();
- //magnetometer->enable();
- //accelerometer->enable();
- //acc_gyro->enable_x();
- //acc_gyro->enable_g();
- #endif
+ /* Enable all sensors */
+ hum_temp->enable();
+ press_temp->enable();
+ //magnetometer->enable();
+ //accelerometer->enable();
+ //acc_gyro->enable_x();
+ //acc_gyro->enable_g();
#endif
