WIO LTE Arduino I2C Compatibility

I can’t seem to get the WIO LTE US VERSION - 4G, CAT.1 board, v1.1 to communicate via I2C with a MPL3115A2

I get these errors:

C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'float Adafruit_MPL3115A2::getPressure()':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:95:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false); // end transmission
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:95:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'float Adafruit_MPL3115A2::getAltitude()':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:134:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false); // end transmission
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:134:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'void Adafruit_MPL3115A2::setSeaPressure(float)':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:157:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false);
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:157:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'float Adafruit_MPL3115A2::getTemperature()':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:177:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false); // end transmission
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:177:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'uint8_t Adafruit_MPL3115A2::read8(uint8_t)':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:204:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false); // end transmission
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:204:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp: In member function 'void Adafruit_MPL3115A2::write8(uint8_t, uint8_t)':
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:222:30: error: no matching function for call to 'TwoWire::endTransmission(int)'
   _i2c->endTransmission(false); // end transmission
                              ^
C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:222:30: note: candidate is:
In file included from C:\Users\liamt\Documents\Arduino\libraries\Adafruit_MPL3115A2_Library-master\Adafruit_MPL3115A2.cpp:33:0:
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note: uint8 TwoWire::endTransmission()
     uint8 endTransmission(void);
           ^
C:\Users\liamt\AppData\Local\Arduino15\packages\Seeeduino\hardware\Seeed_STM32F4\1.2.5\libraries\Wire/Wire.h:85:11: note:   candidate expects 0 arguments, 1 provided
exit status 1
Error compiling for board Wio Tracker LTE.
Invalid library found in C:\Users\liamt\Documents\Arduino\libraries\arduino_555462: no headers files (.h) found in C:\Users\liamt\Documents\Arduino\libraries\arduino_555462

I have been able to fix this error by adjusted the Wire.cpp to include the following:
`
uint8 TwoWire::endTransmission(uint8_t sendStop) { // ******* originally - endTransmission(void) *******
if (tx_buf_overflow) return EDATA;

```
i2c_start(port);

i2c_shift_out(port, (tx_addr << 1) | I2C_WRITE);
if (!i2c_get_ack(port)) return ENACKADDR;

// shift out the address we're transmitting to
for (uint8 i = 0; i < tx_buf_idx; i++) {
	uint8 ret = writeOneByte(tx_buf[i]);
	if (ret) {
		//Serial1.println("endTransmission failed");
		return ret;    // SUCCESS is 0
	}
}

if (sendStop) {				// ******* originally - i2c_stop(port); with no if statement *******
	i2c_stop(port);
}

tx_buf_idx = 0;
tx_buf_overflow = false;
return SUCCESS;
```

}

// This provides backwards compatibility with the original
// definition, and expected behaviour, of endTransmission
//
uint8 TwoWire::endTransmission(void) // ******* Originally function was not included *******
{
return endTransmission(true);
}
`

I also adjusted the Wire.h to include the following
uint8 endTransmission(void); uint8 endTransmission(uint8_t);

This allows the code to run but it does not read the sensor properly as these are the results from the MPL3115A2 sensor connected:

-11.25*C

When it should be 22.5*C

Can your board driver Wire library (the I2C library) please be updated to match this STM32F4 Arduino driver library which does meet Arduino Standard:

//  Originally, 'endTransmission' was an f(void) function.
//  It has been modified to take one parameter indicating
//  whether or not a STOP should be performed on the bus.
//  Calling endTransmission(false) allows a sketch to
//  perform a repeated start.
//
//  WARNING: Nothing in the library keeps track of whether
//  the bus tenure has been properly ended with a STOP. It
//  is very possible to leave the bus in a hung state if
//  no call to endTransmission(true) is made. Some I2C
//  devices will behave oddly if they do not see a STOP.
//
uint8_t TwoWire::endTransmission(uint8_t sendStop)
{
#if !defined(I2C_OTHER_FRAME)
  UNUSED(sendStop);
#endif
  int8_t ret = 4;
  // check transfer options and store it in the I2C handle
#if defined(I2C_OTHER_FRAME)
  if (sendStop == 0) {
_i2c.handle.XferOptions = I2C_OTHER_FRAME ;
  } else {
_i2c.handle.XferOptions = I2C_OTHER_AND_LAST_FRAME;
  }
#endif

  if (_i2c.isMaster == 1) {
// transmit buffer (blocking)
switch (i2c_master_write(&_i2c, txAddress, txBuffer, txBufferLength)) {
  case I2C_OK :
    ret = 0; // Success
    break;
  case I2C_DATA_TOO_LONG :
    ret = 1;
    break;
  case I2C_NACK_ADDR:
    ret = 2;
    break;
  case I2C_NACK_DATA:
    ret = 3;
    break;
  case I2C_TIMEOUT:
  case I2C_BUSY:
  case I2C_ERROR:
  default:
    ret = 4;
    break;
}

// reset Tx buffer
resetTxBuffer();

// reset tx buffer iterator vars
txBufferIndex = 0;
txBufferLength = 0;

// indicate that we are done transmitting
transmitting = 0;
  }
  return ret;
}

//  This provides backwards compatibility with the original
//  definition, and expected behaviour, of endTransmission
//
uint8_t TwoWire::endTransmission(void)
{
  return endTransmission((uint8_t)true);
}

This is how your Wire library is currently configured and does not meet Arduino standard:

uint8 TwoWire::endTransmission(void) {
if (tx_buf_overflow) return EDATA;

i2c_start(port);

i2c_shift_out(port, (tx_addr << 1) | I2C_WRITE);
if (!i2c_get_ack(port)) return ENACKADDR;

// shift out the address we're transmitting to
for (uint8 i = 0; i < tx_buf_idx; i++) {
    uint8 ret = writeOneByte(tx_buf[i]);
    if (ret) {
        //Serial1.println("endTransmission failed");
        return ret;    // SUCCESS is 0
    }
}

i2c_stop(port);

tx_buf_idx = 0;
tx_buf_overflow = false;
return SUCCESS;
}

Hi @trawinlegacy:
I would say, change Wire.endTransmission(false) to Wire.endTransmission() is a good choice in Adafruit MPL3115A2 Library.