Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of Compiler Warnings - At least if I build for a Teensy 4.1 or Micromod #274

Closed
KurtE opened this issue Nov 16, 2022 · 4 comments
Closed
Assignees
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@KurtE
Copy link

KurtE commented Nov 16, 2022

As I mentioned on a PJRC forum post, I have a version of this library building and running on Teensy 4.1 and Micromod using the USBHost_T36 library and a couple of edits to this library. In particular disable the Serial transport and code for its own Transport.
Which now appears to be working. At least with a few of your examples. Like the ones to do with LEDs.

While doing this, I am seeing a lot of compiler warnings in the code. And I believe most of them are not Teensy specific. Note: I am using the latest Teensyduino IDE beta which we are trying a more recent version of GCC which is showing up a lot more compiler warning than earlier ones.

Some of the warnings:

"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1-beta1/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4/pch" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\cores\\teensy4" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\USBHost_T36" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\SDFat\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\SPI" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\EEPROM" "c:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src\\remote\\BLERemoteService.cpp" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4\\libraries\\ArduinoBLE\\remote\\BLERemoteService.cpp.o"
In file included from c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src/utility/GATT.h:26,
                 from c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\local\BLELocalCharacteristic.cpp:25:
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src/local/BLELocalCharacteristic.h: In constructor 'BLELocalCharacteristic::BLELocalCharacteristic(const char*, uint16_t, int, bool)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src/local/BLELocalCharacteristic.h:90:12: warning: 'BLELocalCharacteristic::_cccdValue' will be initialized after [-Wreorder]
   90 |   uint16_t _cccdValue;
      |            ^~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src/local/BLELocalCharacteristic.h:79:12: warning:   'uint8_t BLELocalCharacteristic::_permissions' [-Wreorder]
   79 |   uint8_t  _permissions;
      |            ^~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\local\BLELocalCharacteristic.cpp:32:1: warning:   when initialized here [-Wreorder]
   32 | BLELocalCharacteristic::BLELocalCharacteristic(const char* uuid, uint16_t permissions, int valueSize, bool fixedLength) :
      | ^~~~~~~~~~~~~~~~~~~~~~
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1-beta1/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4/pch" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\cores\\teensy4" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\USBHost_T36" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\SDFat\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\SPI" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\EEPROM" "c:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src\\utility\\GATT.cpp" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4\\libraries\\ArduinoBLE\\utility\\GATT.cpp.o"

And:

"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1-beta1/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=158 -DARDUINO=10607 -DARDUINO_TEENSY_MICROMOD -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4/pch" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\cores\\teensy4" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\USBHost_T36" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\SDFat\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\SPI" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.58.2\\libraries\\EEPROM" "c:\\Users\\kurte\\Documents\\Arduino\\libraries\\ArduinoBLE\\src\\utility\\keyDistribution.cpp" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino-sketch-43071A1C59D1A4F494A82C8D8FA363A4\\libraries\\ArduinoBLE\\utility\\keyDistribution.cpp.o"
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp: In member function 'virtual void HCIClass::poll(long unsigned int)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:141:20: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  141 |     if (_recvIndex >= sizeof(_recvBuffer)) {
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp: In member function 'virtual int HCIClass::tryResolveAddress(uint8_t*, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:565:14: warning: unused variable 'memcheck' [-Wunused-variable]
  565 |     uint8_t* memcheck;
      |              ^~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:557:11: warning: variable 'irk' set but not used [-Wunused-but-set-variable]
  557 |   uint8_t irk[16];
      |           ^~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp: In member function 'virtual void L2CAPSignalingClass::handleSecurityData(uint16_t, uint8_t, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp:271:8: warning: unused variable 'pairingFailed' [-Wunused-variable]
  271 |     } *pairingFailed = (PairingFailed*)data;
      |        ^~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp:320:7: warning: unused variable 'readPublicKeyCommand' [-Wunused-variable]
  320 |     } readPublicKeyCommand = {
      |       ^~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp: In member function 'virtual void L2CAPSignalingClass::smCalculateLTKandConfirm(uint16_t, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp:421:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  421 |     for(int i=0; i<sizeof(Eb); i++){
      |                  ~^~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp: In member function 'virtual void HCIClass::handleEventPkt(uint8_t, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:979:13: warning: unused variable 'BD_ADDRs' [-Wunused-variable]
  979 |     uint8_t BD_ADDRs[num_keys][6];
      |             ^~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:980:13: warning: unused variable 'LKs' [-Wunused-variable]
  980 |     uint8_t LKs[num_keys][16];
      |             ^~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:981:10: warning: variable 'nAddresss' set but not used [-Wunused-but-set-variable]
  981 |     auto nAddresss = [pdata](uint8_t nAddr)->uint8_t*{
      |          ^~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:984:10: warning: variable 'nLK' set but not used [-Wunused-but-set-variable]
  984 |     auto nLK = [pdata](uint8_t nLK)->uint8_t*{
      |          ^~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:999:8: warning: unused variable 'cmdHardwareError' [-Wunused-variable]
  999 |     } *cmdHardwareError = (CmdHardwareError*)&pdata[sizeof(HCIEventHdr)];
      |        ^~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1099:17: warning: unused variable 'address' [-Wunused-variable]
 1099 |         uint8_t address[6];
      |                 ^~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1100:17: warning: variable 'BDAddr' set but not used [-Wunused-but-set-variable]
 1100 |         uint8_t BDAddr[6];
      |                 ^~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1320:25: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 1320 |           for(int i=0; i<sizeof(pairingConfirm.cb);i++){
      |                        ~^~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1330:25: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 1330 |           for(int i=0; i<sizeof(HCI.remotePublicKeyBuffer); i++){
      |                        ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1329:19: warning: variable 'remotePublicKeyReversed' set but not used [-Wunused-but-set-variable]
 1329 |           uint8_t remotePublicKeyReversed[sizeof(HCI.remotePublicKeyBuffer)];
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCI.cpp:1016:7: warning: case value '10' not in enumerated type 'LE_META_EVENT' [-Wswitch]
 1016 |       case 0x0A:{
      |       ^~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp: In member function 'int BluetoothCryptoToolbox::f5(uint8_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp:63:13: warning: variable 'ADD_M' set but not used [-Wunused-but-set-variable]
   63 |     uint8_t ADD_M[7];
      |             ^~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp:64:13: warning: variable 'ADD_S' set but not used [-Wunused-but-set-variable]
   64 |     uint8_t ADD_S[7];
      |             ^~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp: In member function 'void BluetoothCryptoToolbox::testAh()':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp:138:13: warning: variable 'r' set but not used [-Wunused-but-set-variable]
  138 |     uint8_t r[3]   = {0x70,0x81,0x94};
      |             ^
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp:139:13: warning: unused variable 'expected_AES' [-Wunused-variable]
  139 |     uint8_t expected_AES[16] = {0x15,0x9d,0x5f,0xb7,0x2e,0xbe,0x23,0x11,0xa4,0x8c,0x1b,0xdc,0xc4,0x0d,0xfb,0xaa};
      |             ^~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp: In member function 'void BluetoothCryptoToolbox::testg2()':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\btct.cpp:173:13: warning: unused variable 'AES' [-Wunused-variable]
  173 |     uint8_t AES[16] = {0x15,0x36,0xd1,0x8d,0xe3,0xd2,0x0d,0xf9,0x9b,0x70,0x44,0xc1,0x2f,0x9e,0xd5,0xba};
      |             ^~~
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp: In member function 'virtual void L2CAPSignalingClass::handleSecurityData(uint16_t, uint8_t, uint8_t*)':
c:\Users\kurte\Documents\Arduino\libraries\ArduinoBLE\src\utility\L2CAPSignaling.cpp:296:13: warning: 'i' may be used uninitialized [-Wmaybe-uninitialized]
  296 |     for(int i; i<6; i++) peerAddress[5-i] = identityAddress->address[i];
      |             ^
Compiling library "USBHost_t36"

Note: the last one does look like a bug, as the initial value of i is not set...

Now back to experimenting. Right now, trying to figure out why the Peripheral Explorer example, when modified to look at some real hardware, like:
Xbox One controller updated to current firmware (BLE) cannot discover attributes.

Likewise for Microsoft Surface Arc Mouse.
like:

Bluetooth® Low Energy Central - Peripheral Explorer
Found e1:1b:54:3b:1b:21 '' 
Found 20:24:93:53:d2:12 '' 
Found 40:ae:a8:59:63:5b '' 
Found 4d:82:4e:f5:6c:96 '' 
Found 22:7c:49:50:eb:21 '' fd6f
Found 78:ca:b4:94:96:d6 '' 
Found 67:12:a5:9c:57:ad '' 
Found d8:ec:5e:82:11:30 'Linksys' 00002080-8eab-46c2-b788-0e9440016fd1
Found e1:59:47:79:f2:be 'Surface Arc Mouse' 1812
Connecting ...
Connected
Discovering attributes ...
Attribute discovery failed!

Device name: 
Appearance: 0x0

Service Count: 0

Disconnecting ...
Disconnected

But that is probably outside of this issue.

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Nov 17, 2022
@mcl-uk
Copy link

mcl-uk commented May 6, 2023

Hi KurtE, did you ever resolve these issues? I'm seeing the same kind of stuff.

@KurtE
Copy link
Author

KurtE commented May 8, 2023

Sorry @mci-uk I have not looked at it for a while now. It was sort more of a random project I was working on, although it might be nice to figure out the best way to use this on a Teensy. But I was happy that it at least worked, where I could plug a BT dongle into the USBHost port of T3.6 or T4.x and be able to use this library and talk to PC over BLE.

@mcl-uk
Copy link

mcl-uk commented May 8, 2023

I have since made good progress, I fixed most of the compile-time warnings, mostly to do with obsolete debug code (which I also removed) then I hacked HCI.cpp so that it was hard-wired to Serial2 and got rid of HCITransport.*, also sorted out wiring configuration using a new h file. And fixed the baud rate to 115200, after that it finally worked - at least enough for my application. I'll try to get round to posting my hacked version of the ardiunoBLE lib for other Teensy users when I have time.

@per1234 per1234 self-assigned this Jan 28, 2024
@per1234
Copy link
Contributor

per1234 commented Jan 28, 2024

I'm closing this as a duplicate of #310. Even though this one was submitted first, the other contains up to date information about the progress on fixing the code that produces warnings (fortunately most of them have already been fixed via #302).

@per1234 per1234 added the conclusion: duplicate Has already been submitted label Jan 28, 2024
@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants