Skip to content

Commit

Permalink
Fix double closing i2c bus. Indent fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Apr 21, 2022
1 parent 89fa9a0 commit cb2aac3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions libloragw/src/loragw_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ int lgw_start(void) {
}
if (i == sizeof I2C_PORT_TEMP_SENSOR) {
printf("ERROR: no temperature sensor found.\n");
// For RAK2287 this is expected to fail as it has no temperature sensor.
// For RAK2287 this is expected to fail as it has no temperature sensor.
// return LGW_HAL_ERROR;
}

Expand Down Expand Up @@ -1223,11 +1223,13 @@ int lgw_stop(void) {
}

if (CONTEXT_COM_TYPE == LGW_COM_SPI) {
DEBUG_MSG("INFO: Closing I2C for temperature sensor\n");
x = i2c_linuxdev_close(ts_fd);
if (x != 0) {
printf("ERROR: failed to close I2C temperature sensor device (err=%i)\n", x);
err = LGW_HAL_ERROR;
if (ts_fd != -1) {
DEBUG_MSG("INFO: Closing I2C for temperature sensor\n");
x = i2c_linuxdev_close(ts_fd);
if (x != 0) {
printf("ERROR: failed to close I2C temperature sensor device (err=%i)\n", x);
err = LGW_HAL_ERROR;
}
}

if (CONTEXT_BOARD.full_duplex == true) {
Expand Down Expand Up @@ -1291,7 +1293,7 @@ int lgw_receive(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data) {
res = lgw_get_temperature(&current_temperature);
if (res != LGW_I2C_SUCCESS) {
printf("ERROR: failed to get current temperature\n");
// For RAK2287 this is expected to fail as it has no temperature sensor.
// For RAK2287 this is expected to fail as it has no temperature sensor.
// return LGW_HAL_ERROR;
}

Expand Down

0 comments on commit cb2aac3

Please sign in to comment.