Using Basicstation with RAK2287 Concentrator Card

Hi Chris, Thanks for your repsonse, you’re always a welcome name to see pop up.

I’m sure you’re aware from my other posts that I’ve had a fairly constant struggle with the basicstation and RAK2287… Ireally hoped there was just a more straightforward way to get this working hence these alternative routes I’m attempting to conjure up.

With the basicstation stuff I’ve managed to sort out the CUPS authentication with amazon, but I’m not really sure where to start with the alteration of the basicstation software and getting that operational…

The steps I’ve taken so far are:

  1. Create directory in basicstation to hold CUPS and station.conf
  2. Make basicstation with platform=corecell (Corecell uses sx1302 like the RAK2287, which is why I chose this)
  3. Copy a station.conf from one of the corecell examples (examples/corecell/lns-ttn/station.conf)
  4. Make a ‘radio_init.sh’ file for the radio_init option in my station.conf, containing the script below
  5. Run the station from my directory

Any additional input would be very very much appreciated since I’m definitely a bit in over my head now! Even after days of work I’m stalled at this same point.

I’m open to altering what needs altered to try to make this work, but I’m not sure where to find these things, i.e. the SPI speed for the sx1302 and the section that reads from the temperature sensor.

I’m not very familiar with basicstation, but the first question would be if it’s running, and if so if the logs indicate it is able to receive packets.

The I2C temperature and SPI code is probably buried somewhere in the basicstation repo, unless the runtime configuration pulled from the server reaches that deeply(?).

There’s at least one closed (resolved) issue in that repo from someone running a RAK2287, so it doesn’t seem like what you’re trying to do is unprecedented.

It looks like both I2C and SPI are in a separate repo that’s pulled in for the sx1302 when make is run. It already has the SPI speed set at the reduced 2000000.

Semtech have an example in documentation where they have the same I2C error thrown and it seems to have no direct impact on the gateway’s operation in the example…

Could you please point me towards that closed issue? I’ll see if I can extract some sort of solution from whatever was discussed.

https://github.com/lorabasics/basicstation/issues?q=rak2287

I’ve not really worked with basicstation, but my recollection from the classic packet forwarders was that without a patch for the lack of an I2C temperature input things didn’t work at all.

You’ve haven’t really said where your efforts are getting stuck, eg, the the program unwilling to run? If it runs does it receive packets? Do the packets get received but not make it to the network server raw view of things? Or not through to the application side?

Hi Chris,

The gateway just seems unable to start for some reason.
I found another github issue where someone seems to have had success but I face the temperature sensor issue as you predicted.

I suppose where I’m stuck now is how to go about the process of disabling this temperature sensor. The HAL components are pulled in from another repo by the make command, so it’s not like I can just edit one local source file to fix it.

EDIT:
I found this page which details modifying global_conf.json file to remove the need for a temperature sensor: GitHub - JoToSystems/SX1302_UDP_Packet_Forwarder: SX1302 Modified UDP Packet Forwarder

I then went in and added the following two lines…

"temperature_sensor": true,
"temperature_value":25.0

to the basicstation files:
/deps/lgw1302/platform-corecell/packet_forwarder/global_conf.json.sx1257.EU868
and
/deps/lgw1302/git-repo/packet_forwarder/global_conf.json.sx1257.EU868.

These were the closest thing I have that resemble the global_conf.json file for the sx1302.

Follow this I did a make clean and make platform=corecell variant=std. Unfortunately this produced the same outcome. as below.

[email protected]:~/basicstation $ RADIODEV=/dev/spidev0.0 build-corecell-std/bin/station
2021-10-05 09:54:03.572 [SYS:INFO] Logging     : stderr (maxsize=10000000, rotate=3)
2021-10-05 09:54:03.572 [SYS:INFO] Station Ver : 2.0.5(corecell/std) 2021-10-05 09:44:17
2021-10-05 09:54:03.572 [SYS:INFO] Package Ver : (null)
2021-10-05 09:54:03.572 [SYS:INFO] proto EUI   : 0:dca6:3205:f1a        (/sys/class/net/eth0/address)
2021-10-05 09:54:03.572 [SYS:INFO] prefix EUI  : ::1    (builtin)
2021-10-05 09:54:03.572 [SYS:INFO] Station EUI : dca6:32ff:fe05:f1a
2021-10-05 09:54:03.572 [SYS:INFO] Station home: ./     (builtin)
2021-10-05 09:54:03.572 [SYS:INFO] Station temp: /var/tmp/      (builtin)
2021-10-05 09:54:03.774 [TCE:INFO] Starting TC engine
2021-10-05 09:54:03.775 [any:INFO] ./tc.trust:
cert. version     : 3
serial number     : A7:0E:4A:4C:34:82:B7:7F
issuer name       : C=US, O=Starfield Technologies, Inc., OU=Starfield Class 2 Certification Authority
subject name      : C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, Inc., CN=Starfield Services Root Certificate Authority - G2
issued  on        : 2009-09-02 00:00:00
expires on        : 2034-06-28 17:39:16
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic con2021-10-05 09:54:03.781 [any:INFO] ./tc.crt:
cert. version     : 3
serial number     : 5D:D1:7B:E4:F2:3F:36:85:54:FA:4B:4E:55:5E:1A:CE:D2:2D:87:7B
issuer name       : OU=Amazon Web Services O=Amazon.com Inc. L=Seattle ST=Washington C=US
subject name      : CN=AWS IoT Certificate
issued  on        : 2021-10-05 09:47:42
expires on        : 2049-12-31 23:59:59
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic constraints : CA=false
key usage         : Digital Signature
2021-10-05 09:54:03.781 [AIO:INFO]
2021-10-05 09:54:04.014 [TCE:INFO] Connecting to INFOS: wss://A3OQ74V8656RDU.lns.lorawan.us-west-2.amazonaws.com:443
2021-10-05 09:54:04.014 [CUP:INFO] Starting a CUPS session in 0 seconds.
2021-10-05 09:54:04.014 [CUP:INFO] Starting a CUPS session now.
2021-10-05 09:54:04.014 [CUP:INFO] Connecting to CUPS ... https://A3OQ74V8656RDU.cups.lorawan.us-west-2.amazonaws.com:443 (try #1)
2021-10-05 09:54:04.014 [any:INFO] ./cups.trust:
cert. version     : 3
serial number     : A7:0E:4A:4C:34:82:B7:7F
issuer name       : C=US, O=Starfield Technologies, Inc., OU=Starfield Class 2 Certification Authority
subject name      : C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, Inc., CN=Starfield Services Root Certificate Authority - G2
issued  on        : 2009-09-02 00:00:00
expires on        : 2034-06-28 17:39:16
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic c2021-10-05 09:54:04.022 [any:INFO] ./cups.crt:
cert. version     : 3
serial number     : 2F:B2:92:89:7F:3C:5C:D7:89:CB:36:E6:5A:1B:82:93:A7:9D:AF:B6
issuer name       : OU=Amazon Web Services O=Amazon.com Inc. L=Seattle ST=Washington C=US
subject name      : CN=AWS IoT Certificate
issued  on        : 2021-09-27 10:25:44
expires on        : 2049-12-31 23:59:59
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic constraints : CA=false
key usage         : Digital Signature
2021-10-05 09:54:04.022 [AIO:INFO]
2021-10-05 09:54:04.266 [CUP:VERB] Retrieving update-info from CUPS https://A3OQ74V8656RDU.cups.lorawan.us-west-2.amazonaws.com:443...
2021-10-05 09:54:05.057 [AIO:DEBU] [4] HTTP connection shutdown...
2021-10-05 09:54:05.057 [CUP:INFO] Interaction with CUPS done (no updates) - next regular check in 1d
2021-10-05 09:54:05.108 [TCE:INFO] Infos: dca6:32ff:fe05:0f1a dca6:32ff:fe05:0f1a wss://A3OQ74V8656RDU.lns.lorawan.us-west-2.amazonaws.com:443/gateway/dca632fffe050f1a
2021-10-05 09:54:05.108 [AIO:DEBU] [3] ws_close reason=1000
2021-10-05 09:54:05.108 [AIO:DEBU] Echoing close - reason=1000
2021-10-05 09:54:05.108 [AIO:DEBU] [3|WS] Server sent close: reason=1006
2021-10-05 09:54:05.108 [AIO:DEBU] [3] WS connection shutdown...
2021-10-05 09:54:05.108 [any:INFO] ./tc.trust:
cert. version     : 3
serial number     : A7:0E:4A:4C:34:82:B7:7F
issuer name       : C=US, O=Starfield Technologies, Inc., OU=Starfield Class 2 Certification Authority
subject name      : C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, Inc., CN=Starfield Services Root Certificate Authority - G2
issued  on        : 2009-09-02 00:00:00
expires on        : 2034-06-28 17:39:16
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic con2021-10-05 09:54:05.111 [any:INFO] ./tc.crt:
cert. version     : 3
serial number     : 5D:D1:7B:E4:F2:3F:36:85:54:FA:4B:4E:55:5E:1A:CE:D2:2D:87:7B
issuer name       : OU=Amazon Web Services O=Amazon.com Inc. L=Seattle ST=Washington C=US
subject name      : CN=AWS IoT Certificate
issued  on        : 2021-10-05 09:47:42
expires on        : 2049-12-31 23:59:59
signed using      : RSA with SHA-256
RSA key size      : 2048 bits
basic constraints : CA=false
key usage         : Digital Signature
2021-10-05 09:54:05.111 [AIO:INFO]
2021-10-05 09:54:05.332 [TCE:VERB] Connecting to MUXS...
2021-10-05 09:54:06.173 [TCE:VERB] Connected to MUXS.
2021-10-05 09:54:06.359 [S2E:WARN] Unknown field in router_config - ignored: protocol (0xFD309030)
2021-10-05 09:54:06.359 [S2E:WARN] Unknown field in router_config - ignored: regionid (0xE6FFB211)
2021-10-05 09:54:06.360 [SYS:VERB] rinit.sh: Forked, waiting...
CoreCell reset through GPIO17...
CoreCell power enable through GPIO18...
2021-10-05 09:54:07.112 [SYS:INFO] Process rinit.sh (pid=3105) completed
ERROR: Failed to stop TX trigger
ERROR: Failed to stop TX trigger
ERROR: failed to close I2C device (err=-1)
2021-10-05 09:54:07.113 [RAL:INFO] Lora gateway library version: Version: 1.0.5;
2021-10-05 09:54:07.129 [RAL:VERB] Connecting to device: /dev/spidev0.0
2021-10-05 09:54:07.129 [RAL:DEBU] SX130x txlut table (16 entries)
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  0:  rf_power=12 pa_gain=0 pwr_idx=15
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  1:  rf_power=13 pa_gain=0 pwr_idx=16
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  2:  rf_power=14 pa_gain=0 pwr_idx=17
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  3:  rf_power=15 pa_gain=0 pwr_idx=19
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  4:  rf_power=16 pa_gain=0 pwr_idx=20
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  5:  rf_power=17 pa_gain=0 pwr_idx=22
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  6:  rf_power=18 pa_gain=1 pwr_idx=1
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  7:  rf_power=19 pa_gain=1 pwr_idx=2
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  8:  rf_power=20 pa_gain=1 pwr_idx=3
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut  9:  rf_power=21 pa_gain=1 pwr_idx=4
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 10:  rf_power=22 pa_gain=1 pwr_idx=5
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 11:  rf_power=23 pa_gain=1 pwr_idx=6
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 12:  rf_power=24 pa_gain=1 pwr_idx=7
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 13:  rf_power=25 pa_gain=1 pwr_idx=9
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 14:  rf_power=26 pa_gain=1 pwr_idx=11
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 txlut 15:  rf_power=27 pa_gain=1 pwr_idx=14
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 rssi_tcomp: coeff_a=0.000 coeff_b=0.000 coeff_c=20.410 coeff_d=2162.560 coeff_e=0.000
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 rxrfchain 0: enable=1 freq=867.5MHz rssi_offset=-215.399994 type=5 tx_enable=1
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 rxrfchain 1: enable=1 freq=868.5MHz rssi_offset=-215.399994 type=5 tx_enable=0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  0: enable=1 rf_chain=0 freq=-400000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  1: enable=1 rf_chain=0 freq=-200000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  2: enable=1 rf_chain=0 freq=0 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  3: enable=1 rf_chain=0 freq=200000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  4: enable=1 rf_chain=0 freq=400000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  5: enable=1 rf_chain=1 freq=-400000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  6: enable=1 rf_chain=1 freq=-200000 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  7: enable=1 rf_chain=1 freq=0 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  8: enable=1 rf_chain=1 freq=-200000 bw=5 SF=7 sync_word=0/0 [STD] Explicit header
2021-10-05 09:54:07.129 [RAL:VERB] SX1302 ifchain  9: enable=1 rf_chain=0 freq=0 bw=0 SF=0 sync_word=0/0
2021-10-05 09:54:07.129 [RAL:VERB] Station device: /dev/spidev0.0 (PPS capture disabled)
ERROR: invalid I2C file descriptor
ERROR: invalid I2C file descriptor
ERROR: failed to configure the temperature sensor
2021-10-05 09:54:09.669 [RAL:ERRO] Concentrator start failed: lgw_start
2021-10-05 09:54:09.669 [RAL:ERRO] ral_config failed with status 0x08
2021-10-05 09:54:09.669 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2021-10-05 09:54:09.669 [AIO:DEBU] [3] ws_close reason=1000
2021-10-05 09:54:09.669 [AIO:DEBU] Echoing close - reason=1000
2021-10-05 09:54:09.853 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2021-10-05 09:54:09.853 [AIO:DEBU] [3] WS connection shutdown...
2021-10-05 09:54:09.854 [TCE:VERB] Connection to MUXS closed in state -1
2021-10-05 09:54:09.854 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)

I suspect actually that is what you want to do.

It looks fairly likely that it will only pull in the sx1302 libloragw the first time you do a build for a particular configuration, and that if you then modify it and re-build that won’t be pulled in again, but backup your changes to be sure.

If you need to go further you could modify the basicstation/prep.sh at master · lorabasics/basicstation · GitHub script to not pull in the git repo, or pull in your own fork of it instead. Long run the patch mechanism in basicstation could perhaps be leveraged to do so automatically.

Hi Chris,

I literally just managed to resolve this

From a fresh clone from the repo I did a make platform=corecell variant to pull in the dependencies (mainly GitHub - Lora-net/sx1302_hal: SX1302/SX1303 Hardware Abstraction Layer and Tools (packet forwarder...)).

After that I edited ~/basicstation/deps/lgw1302/platform-corecell/libloragw/src/loragw_stts751.c to comment out any I2C calls, and return a static temperature value as below;

/*
 / _____)             _              | |
( (____  _____ ____ _| |_ _____  ____| |__
 \____ \| ___ |    (_   _) ___ |/ ___)  _ \
 _____) ) ____| | | || |_| ____( (___| | | |
(______/|_____)_|_|_| \__)_____)\____)_| |_|
  (C)2019 Semtech

Description:
    Basic driver for ST ts751 temperature sensor

License: Revised BSD License, see LICENSE.TXT file include in the project
*/


/* -------------------------------------------------------------------------- */
/* --- DEPENDANCIES --------------------------------------------------------- */

#include <stdint.h>     /* C99 types */
#include <stdbool.h>    /* bool type */
#include <stdio.h>      /* printf fprintf */

#include "loragw_i2c.h"
#include "loragw_stts751.h"

/* -------------------------------------------------------------------------- */
/* --- PRIVATE MACROS ------------------------------------------------------- */

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#if DEBUG_I2C == 1
    #define DEBUG_MSG(str)              fprintf(stdout, str)
    #define DEBUG_PRINTF(fmt, args...)  fprintf(stdout,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
    #define CHECK_NULL(a)               if(a==NULL){fprintf(stderr,"%s:%d: ERROR: NULL POINTER AS ARGUMENT\n", __FUNCTION__, __LINE__);return LGW_REG_ERROR;}
#else
    #define DEBUG_MSG(str)
    #define DEBUG_PRINTF(fmt, args...)
    #define CHECK_NULL(a)               if(a==NULL){return LGW_REG_ERROR;}
#endif

/* -------------------------------------------------------------------------- */
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */

#define STTS751_REG_TEMP_H      0x00
#define STTS751_REG_STATUS      0x01
#define STTS751_STATUS_TRIPT    BIT(0)
#define STTS751_STATUS_TRIPL    BIT(5)
#define STTS751_STATUS_TRIPH    BIT(6)
#define STTS751_REG_TEMP_L      0x02
#define STTS751_REG_CONF        0x03
#define STTS751_CONF_RES_MASK   0x0C
#define STTS751_CONF_RES_SHIFT  2
#define STTS751_CONF_EVENT_DIS  BIT(7)
#define STTS751_CONF_STOP       BIT(6)
#define STTS751_REG_RATE        0x04
#define STTS751_REG_HLIM_H      0x05
#define STTS751_REG_HLIM_L      0x06
#define STTS751_REG_LLIM_H      0x07
#define STTS751_REG_LLIM_L      0x08
#define STTS751_REG_TLIM        0x20
#define STTS751_REG_HYST        0x21
#define STTS751_REG_SMBUS_TO    0x22

#define STTS751_REG_PROD_ID     0xFD
#define STTS751_REG_MAN_ID      0xFE
#define STTS751_REG_REV_ID      0xFF

#define STTS751_0_PROD_ID       0x00
#define STTS751_1_PROD_ID       0x01
#define ST_MAN_ID               0x53

/* -------------------------------------------------------------------------- */
/* --- PRIVATE VARIABLES ---------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/* --- PRIVATE FUNCTIONS ---------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */

int stts751_configure(int i2c_fd, uint8_t i2c_addr) {
#if 0    
    int err;
    uint8_t val;


    /* Check Input Params */
    if (i2c_fd <= 0) {
        printf("ERROR: invalid I2C file descriptor\n");
        return LGW_I2C_ERROR;
    }

    DEBUG_PRINTF("INFO: configuring STTS751 temperature sensor on 0x%02X...\n", i2c_addr);

    /* Get product ID  and test which sensor is mounted */
    err = i2c_linuxdev_read(i2c_fd, i2c_addr, STTS751_REG_PROD_ID, &val);
    if (err != 0) {
        DEBUG_PRINTF("ERROR: failed to read I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }
    switch (val) {
        case STTS751_0_PROD_ID:
            DEBUG_MSG("INFO: Product ID: STTS751-0\n");
            break;
        case STTS751_1_PROD_ID:
            DEBUG_MSG("INFO: Product ID: STTS751-1\n");
            break;
        default:
            printf("ERROR: Product ID: UNKNOWN\n");
            return LGW_I2C_ERROR;
    }

    /* Get Manufacturer ID */
    err = i2c_linuxdev_read(i2c_fd, i2c_addr, STTS751_REG_MAN_ID, &val);
    if (err != 0) {
        DEBUG_PRINTF("ERROR: failed to read I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }
    if (val != ST_MAN_ID) {
        printf("ERROR: Manufacturer ID: UNKNOWN\n");
        return LGW_I2C_ERROR;
    } else {
        DEBUG_PRINTF("INFO: Manufacturer ID: 0x%02X\n", val);
    }

    /* Get revision number */
    err = i2c_linuxdev_read(i2c_fd, i2c_addr, STTS751_REG_REV_ID, &val);
    if (err != 0) {
        DEBUG_PRINTF("ERROR: failed to read I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }
    DEBUG_PRINTF("INFO: Revision number: 0x%02X\n", val);

    /* Set conversion resolution to 12 bits */
    err = i2c_linuxdev_write(i2c_fd, i2c_addr, STTS751_REG_CONF, 0x8C); /* TODO: do not hardcode the whole byte */
    if (err != 0) {
        DEBUG_PRINTF("ERROR: failed to write I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }

    /* Set conversion rate to 1 / second */
    err = i2c_linuxdev_write(i2c_fd, i2c_addr, STTS751_REG_RATE, 0x04);
    if (err != 0) {
        DEBUG_PRINTF("ERROR: failed to write I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }
#endif

    return LGW_I2C_SUCCESS;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

int stts751_get_temperature(int i2c_fd, uint8_t i2c_addr, float * temperature) {
#if 0
    int err;
    uint8_t high_byte, low_byte;
    int8_t h;

    /* Check Input Params */
    if (i2c_fd <= 0) {
        printf("ERROR: invalid I2C file descriptor\n");
        return LGW_I2C_ERROR;
    }

    /* Read Temperature LSB */
    err = i2c_linuxdev_read(i2c_fd, i2c_addr, STTS751_REG_TEMP_L, &low_byte);
    if (err != 0) {
        printf("ERROR: failed to read I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }

    /* Read Temperature MSB */
    err = i2c_linuxdev_read(i2c_fd, i2c_addr, STTS751_REG_TEMP_H, &high_byte);
    if (err != 0) {
        printf("ERROR: failed to read I2C device 0x%02X (err=%i)\n", i2c_addr, err);
        return LGW_I2C_ERROR;
    }

    h = (int8_t)high_byte;
    *temperature = ((h << 8) | low_byte) / 256.0;
#endif
    *temperature = 25.0;

    DEBUG_PRINTF("Temperature: %f C (h:0x%02X l:0x%02X)\n", *temperature, 0, 0);

    return LGW_I2C_SUCCESS;
}

/* --- EOF ------------------------------------------------------------------ */

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.