arduino-libraries / ArduinoBLE

ArduinoBLE library for Arduino
GNU Lesser General Public License v2.1
308 stars 205 forks source link

Compiler warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated #164

Open rmlearney opened 3 years ago

rmlearney commented 3 years ago
libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp: In function 'void bleLoop()':
libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:123:68: warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer microseconds are needed, you can use `elapsed_time().count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         last_update_us += (uint64_t) timer.read_high_resolution_us();
                                                                    ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:81:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/drivers/Timer.h:104:20: note: declared here
     us_timestamp_t read_high_resolution_us() const;
                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:145:72: warning: 'us_timestamp_t mbed::TimerBase::read_high_resolution_us() const' is deprecated: Use the Chrono-based elapsed_time method.  If integer microseconds are needed, you can use `elapsed_time().count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         uint64_t time_spent = (uint64_t) timer.read_high_resolution_us();
                                                                        ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:81:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/drivers/Timer.h:104:20: note: declared here
     us_timestamp_t read_high_resolution_us() const;
                    ^~~~~~~~~~~~~~~~~~~~~~~
/Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:156:55: warning: 'void rtos::ThisThread::sleep_for(uint32_t)' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
               rtos::ThisThread::sleep_for(wait_time_ms);
                                                       ^
In file included from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/rtos/rtos.h:30:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/mbed.h:23,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed.h:14,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/Arduino.h:42,
                 from /Users/xxxx/Documents/Arduino/libraries/ArduinoBLE/src/utility/HCICordioTransport.cpp:22:
/Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.3.2/cores/arduino/mbed/rtos/ThisThread.h:216:6: note: declared here
 void sleep_for(uint32_t millisec);
      ^~~~~~~~~
paulvha commented 1 year ago

These are just warnings for now, but these calls will be depreciated in the future. instead of (uint64_t) timer.read_high_resolution_us(); use (uint64_t) timer.elapsed_time().count();

and instead of rtos::ThisThread::sleep_for(wait_time_ms); use rtos::ThisThread::sleep_for(mbed::chrono::milliseconds_u32(wait_time_ms));