tcoppex / mbed-ble-hid Goto Github PK
View Code? Open in Web Editor NEW:raising_hand: Implement Human Interface Device over Bluetooth Low Energy on a Mbed stack (Arduino nano 33 BLE).
License: MIT License
:raising_hand: Implement Human Interface Device over Bluetooth Low Energy on a Mbed stack (Arduino nano 33 BLE).
License: MIT License
Hi ,
this code works perfrectly with Android device and W10 PC with native BT adaperr. On my desktop with W7 and a CRS Harmony BT usb adaper it doesn't ,because return the message "wrong code entered" , like if he try to do a pairing with pin code , while on Android and other PC isn't required the pairing with pin code. Is there any way to solve this issue ? Tks. Roberto
I am not able to send function keys using this library. Is there a problem with me (I assume) or with the library? I have used the Arduino forum with no luck. I am using the ble_shining_kb example with a Nano 33 BLE and I can send text but just cannot send a control character from the HIDKeyboardService.h ...
sendCharacter(LEFT_ARROW);
or
KeySym_t testSym_t = KeySym_t(LEFT_ARROW,0); kb->keydown(testSym_t); kb->keyup();
I have a simple platformio project.
Compiling gives the following error:
.pio\libdeps\nano33ble\Mbed BLE HID\src\Mbed_BLE_HID.cpp:151:30: error: call of overloaded 'millis()' is ambiguous
I have also tried version 1.3.0 with same outcome.
Older than 1.2.0 give other errors.
What could be the problem?
platformio.ini
[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
lib_deps =
tcoppex/Mbed BLE [email protected]
main.cpp
#include <Arduino.h>
#include <USBKeyboard.h>
static USBKeyboard Keyboard;
void setup(){
}
void loop(){
delay(1000);
Keyboard.printf("Hello world\n\r");
}
Looking within the HIDService.h, I can see that output reports are only partially supported, with the BLE characteristic defined and enum values. However there is no method of receiving the report. I've tried to expand upon this with the following function, however it doesn't seem to work. Did you have any implementation in mind for this functionality?
void ReceiveReport() {
ble.gattServer().read(
outputReportChar.getValueHandle(),
(uint8_t*)outputReport,
(uint16_t*)outputReportLength
);
}
Hello
In the arduino IDE 1.8.13 the examples are shown as "INCOMPATIBLE" although I have selected the Arduino Nano 33 BLE.
But I can compile both examples "ble_shining_kb" and "ble_mouse" it and upload it to the Arduino Nano 33 BLE.
Then on my Android and Windows device I see for example the shining keyboard but can't connect to it.
And also the Arduino Nano 33 BLE shows an error with slowly turning its LED on and off.
I'm using the examples as is. (No modifications)
So my questions:
When I try and compile the shining keyboard example on an MBED board running version 1.3.0 I get the following errors:
In file included from /Users/bsperryn/Documents/Arduino/shining_keyboard/shining_keyboard.ino:12:0:
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/signal_utils.h:55:7: warning: 'float {anonymous}::randf(float, float)' defined but not used [-Wunused-function]
float randf(float edge0=0.0f, float edge1=1.0f) {
^~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/signal_utils.h:39:7: warning: 'float {anonymous}::mmap(float, float, float, float, float)' defined but not used [-Wunused-function]
float mmap(float x, float a, float b, float c, float d) {
^~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/signal_utils.h:17:7: warning: 'float {anonymous}::step(float, float)' defined but not used [-Wunused-function]
float step(float a, float x) {
^~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp: In static member function 'static void MbedBleHID::RunEventThread(void (*)())':
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:46:36: warning: 'int events::EventQueue::call_every(int, Mbed_F) [with Mbed_F = void (*)()]' 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]
eventQueue.call_every(10, task_fn);
^
In file included from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed/events/mbed_events.h:21:0,
from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed/mbed.h:32,
from /Users/briansperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed.h:14,
from /Users/briansperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:7,
from /Users/briansperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:2:
/Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed/events/EventQueue.h:1063:9: note: declared here
int call_every(int ms, F f)
^~~~~~~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:53:44: 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(osWaitForever);
^
In file included from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed/rtos/rtos.h:30:0,
from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/USB/PluggableUSBSerial.h:24,
from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/Arduino.h:131,
from /Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed.h:4,
from /Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:7,
from /Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:2:
/Users/bsperryn/Library/Arduino15/packages/arduino/hardware/mbed/1.3.0/cores/arduino/mbed/rtos/ThisThread.h:216:6: note: declared here
void sleep_for(uint32_t millisec);
^~~~~~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp: In member function 'void MbedBleHID::postInitialization(BLE&)':
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:105:14: error: 'ConnectionParams_t' in 'Gap {aka class ble::interface::Gap<ble::generic::GenericGap<ble::pal::vendor::cordio::Gap, ble::pal::SecurityManager<ble::pal::vendor::cordio::CordioSecurityManager<ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> >, ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> >, ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> > >}' does not name a type
const Gap::ConnectionParams_t connectionParams = {
^~~~~~~~~~~~~~~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:111:7: error: 'Gap {aka class ble::interface::Gap<ble::generic::GenericGap<ble::pal::vendor::cordio::Gap, ble::pal::SecurityManager<ble::pal::vendor::cordio::CordioSecurityManager<ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> >, ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> >, ble::generic::GenericSecurityManager<ble::pal::vendor::cordio::CordioSecurityManager, ble::vendor::cordio::SigningEventMonitor> > >}' has no member named 'setPreferredConnectionParams'; did you mean 'PreferredConnectionParams_t'?
gap.setPreferredConnectionParams(&connectionParams);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
PreferredConnectionParams_t
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:111:37: error: 'connectionParams' was not declared in this scope
gap.setPreferredConnectionParams(&connectionParams);
^~~~~~~~~~~~~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:111:37: note: suggested alternative: 'connection_time'
gap.setPreferredConnectionParams(&connectionParams);
^~~~~~~~~~~~~~~~
connection_time
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:120:19: error: 'GapAdvertisingData' has not been declared
.setFlags(GapAdvertisingData::BREDR_NOT_SUPPORTED
^~~~~~~~~~~~~~~~~~
/Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:121:19: error: 'GapAdvertisingData' has not been declared
| GapAdvertisingData::LE_GENERAL_DISCOVERABLE
^~~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Arduino Nano 33 BLE.
This library looks great, the only problem I have is that I'm trying to get it to work with my Nano IOT which uses the SAMD (32-bit ARM Cortex) with a NinaW102.
What would it take to get it working with this board?
Hello
I have a small arduino sketch for the Arduino Nano 33 BLE.
firmware.zip
Board Library:
I try to mix BLE functionality with the USBKeyboard.
Both individually work fine.
But as soon as I try to use both it still compiles but the Arduino crashes:
LED no longer blinking and BLE device no longer discoverable.
Is it possible that the USBKeyboard influences BLE?
Hi there, I'm just wondering what the state of this repo is? (abandoned, forgotten about, original author doesn't have enough time, etc). I saw the deprecation notice on the readme but can't see any information about why, so some info on that would also be great
I'm needing to use an Arduino Nano BLE as a keyboard for a year-long research project, so if someone can update me on current issues/problems or why the project was deprecated, that would be amazing. I have a fair amount of time to dedicate to making this a working interface and would love to do so, but don't really want to go in blind unless I have to.
Thanks!
When using the Arduino Mbed OS Nano Boards
board definition with version 2.2.0 the initial pairing request fails indicating that the passphrase was wrong.
2.0.0 appears to work.
I uploaded ble_shining_kb to NANO 33 BLE and tried to pair with many Android , iOS phones and PCs but always I got error in paring.!!!!!
Hi, I have been trying to use the shining keyboard example on iOS but failed to. The pairing with my iPhone or iPad breaks very soon. I read a few documents from Apple, wondering if it's because the transmission is not encrypted. Also when I use LightBlue to test on the shining keyboard, the pairing breaks, too, and LightBlue reported error: the data is staled. If would be great if you can look into it!
Using BLE nano 33 Sense with Arduino nRF528x boards (Mbed OS) with version 1.1.6 I get the following errors when I add this line at the top of my sketch: #include <Nano33BleHID.h>
In file included from /Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/DeviceInformationService.h:20:0,
from /Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:8,
from /Users/bsperryn/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4,
from /Users/bsperryn/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/BLE.h:bsperryn:9: error: 'BLE' does not name a type
typedef BLE BLEDevice;
^~~
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:8:0,
from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/DeviceInformationService.h:51:41: error: expected ')' before '&' token
DeviceInformationService(BLE &_ble,
^
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/DeviceInformationService.h:113:5: error: 'BLE' does not name a type
BLE &ble;
^~~
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:9:0,
from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/BatteryService.h:70:24: error: expected ')' before '&' token
BatteryService(BLE &_ble, uint8_t level = 100) :
^
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:9:0,
from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/BatteryService.h:121:5: error: 'BLE' does not name a type
BLE &ble;
^~~
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/BatteryService.h: In member function 'void BatteryService::updateBatteryLevel(uint8_t)':
/Users/bs/Library/Arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/features/FEATURE_BLE/ble/services/BatteryService.h:107:12: error: expected primary-expression before '.' token
ble.gattServer().write(
^
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:11:0,
from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h: At global scope:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:93:18: error: expected ')' before '&' token
HIDService(BLE &_ble,
^
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:255:3: error: 'BLE' does not name a type
BLE &ble;
^~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:260:21: warning: non-static const member 'uint8_t* const HIDService::inputReport' in class without a constructor [-Wuninitialized]
report_t inputReport;
^~~~~~~~~~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:263:21: warning: non-static const member 'uint8_t* const HIDService::outputReport' in class without a constructor [-Wuninitialized]
report_t outputReport;
^~~~~~~~~~~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:266:21: warning: non-static const member 'uint8_t* const HIDService::featureReport' in class without a constructor [-Wuninitialized]
report_t featureReport;
^~~~~~~~~~~~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h: In member function 'void HIDService::SendReport()':
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDService.h:247:8: error: expected primary-expression before '.' token
ble.gattServer().write(
^
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:4:0,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h: At global scope:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:52:58: error: 'BLE' is not a type
virtual std::shared_ptr<HIDService> CreateHIDService(BLE &ble) = 0;
^~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:55:29: error: 'BLE' is not a type
void postInitialization(BLE &ble);
^~~
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.h:109:50: error: 'BLE' is not a type
std::shared_ptr<HIDService> CreateHIDService(BLE &ble) override {
^~~
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:12:0,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDMouseService.h:30:23: error: expected ')' before '&' token
HIDMouseService(BLE &_ble);
^
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:13:0,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDKeyboardService.h:77:26: error: expected ')' before '&' token
HIDKeyboardService(BLE &_ble);
^
In file included from /Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/Nano33BleHID.h:14:0,
from /Users/bs/Documents/Arduino/1_button_sketch/1_button_sketch.ino:2:
/Users/bs/Documents/Arduino/libraries/Mbed_BLE_HID/src/services/HIDGamepadService.h:33:25: error: expected ')' before '&' token
HIDGamepadService(BLE &_ble);
^
exit status 1
Error compiling for board Arduino Nano 33 BLE.
Trying to compile the keyboard example in the IDE results in the errors below.
Arduino IDE 1.8.13
OS: MacOS
BN: Arduino Nano 33 BLE
VID: 2341
PID: 805a
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp: In member function 'long unsigned int MbedBleHID::connection_time() const':
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:70:10: error: 'millis' was not declared in this scope
return millis() - lastConnection_;
^~~~~~
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:70:10: note: suggested alternative: 'malloc'
return millis() - lastConnection_;
^~~~~~
malloc
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp: In member function 'virtual void MbedBleHID::onConnectionComplete(const ble::ConnectionCompleteEvent&)':
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:159:23: error: 'millis' was not declared in this scope
lastConnection_ = millis();
^~~~~~
/Users/REMOVED/Documents/Arduino/libraries/Mbed_BLE_HID/src/Mbed_BLE_HID.cpp:159:23: note: suggested alternative: 'malloc'
lastConnection_ = millis();
^~~~~~
malloc
exit status 1
Error compiling for board Arduino Nano 33 BLE.
This is a lack of knowledge about BLE and Bluetooth -- I will admit that up front.
Got a Arduino 33 BLE -- Loaded Shining Keyboard
I see it on the LightBlue App -- ask to connect -- it starts
I get a pairing bubble on the screen -- then a quick bubble saying it needs a PIN.
in the Sketch -- how do you supply a PIN ??
thanks in advance for any help
Greg
I could pair ble Shining Keyboard after downgrading the Arduino Mbed OS Nano Boards to the 2.1.0 version.
My issue is How can I make the Nano board memorize that it has been paired with other BLE devices before and connect automatically.
BR
I was able to run this library on Nano 33 ble with Mbed OS 2.1 and mbed-ble-hid 1.2 but there were few problems (tested on windows 10 as bt joystick):
Things I would love to see added:
Thank you for your work so far, I hope that this project gets an update soon because it's awesome.
Hi, I've tried to modified the hid_report_map in HIDGamepadService.cpp to 16-bit version as following.
// Report Map with two joysticks for Android
static uint8_t hid_report_map[] =
{
USAGE_PAGE(1), 0x01, // Usage Page (Generic Desktop)
USAGE(1), 0x05, // Usage (Game Pad)
COLLECTION(1), 0x01, // Collection (Application)
// Buttons
USAGE_PAGE(1), 0x09, // Usage Page (Buttons)
USAGE_MINIMUM(1), 0x01, // Usage Minimum (1)
USAGE_MAXIMUM(1), 0x0c, // Usage Maximum (12)
LOGICAL_MINIMUM(1), 0x00, // Logical Minimum (0)
LOGICAL_MAXIMUM(1), 0x01, // Logical Maximum (1)
REPORT_COUNT(1), 0x0c, // Report Count (12)
REPORT_SIZE(1), 0x01, // Report Size (1)
INPUT(1), 0x02, // Input (Data, Variable, Absolute)
// (padding)
REPORT_COUNT(1), 0x01, // Report Count (1)
REPORT_SIZE(1), 0x04, // Report Size (4)
INPUT(1), 0x01, // Input (Constant) for padding
// joysticks
USAGE_PAGE(1), 0x01, // Usage Page (Generic Desktop)
USAGE(1), 0x01, // Usage (Pointer)
LOGICAL_MINIMUM(2), 0x01, 0x80, // Logical Minimum (-32767)
LOGICAL_MAXIMUM(2), 0xFF, 0x7F, // Logical Maximum (32767)
REPORT_SIZE(1), 0x10, // Report Size (16)
REPORT_COUNT(1), 0x04, // Report Count (4)
COLLECTION(1), 0x00, // Collection (Physical)
USAGE(1), 0x30, // Usage (X)
USAGE(1), 0x31, // Usage (Y)
USAGE(1), 0x32, // Usage (Z)
USAGE(1), 0x35, // Usage (Rz)
INPUT(1), 0x02, // Input (Data, Variable, Absolute)
END_COLLECTION(0), // End Collection (Physical)
END_COLLECTION(0), // End Collection (Application)
};
The motion function was changed to following:
void HIDGamepadService::motion(float fx, float fy, float fz, float frz) {
uint16_t x = static_cast<int>(0x10000 + fx * 0x7fff) & 0xffff;
uint16_t y = static_cast<int>(0x10000 + fy * 0x7fff) & 0xffff;
uint16_t z = static_cast<int>(0x10000 + fz * 0x7fff) & 0xffff;
uint16_t rz = static_cast<int>(0x10000 + frz * 0x7fff) & 0xffff;
hid_input_report.x_l = (uint8_t)(x & 0x00FF); // lower 8-bit
hid_input_report.x_h = (uint8_t)(x>>8); // higher 8-bit
hid_input_report.y_l = (uint8_t)(y & 0x00FF);;
hid_input_report.y_h = (uint8_t)(y>>8);;
hid_input_report.z_l = (uint8_t)(z & 0x00FF);;
hid_input_report.z_h = (uint8_t)(z>>8);;
hid_input_report.rz_l = (uint8_t)(rz & 0x00FF);;
hid_input_report.rz_h = (uint8_t)(rz>>8);;
}
Compilation and flashing on Arduino Nano Ble 33 was successful. On Windows it reported
This device cannot start. (Code 10)
Report was not byte aligned.
I googled around and found out that Mbed should support 16-bit HID (https://os.mbed.com/questions/1318/16-bit-values-for-a-joystick/). The original 8-bit version worked perfectly.
What might go wrong here? Thanks.
Hi. Just to note:
I tried to compile an empty project (just libraries) in VisualStudio Code and PlatformIO's IDE plugin. Previously, I downloaded and installed mbed-ble-hid using the builtin library manager. Then I came into some compilation errors and warnings at Mbed_BLE_HID.cpp.
PlatformIO's library manager seems to download an outdated version.
I downloaded a fresh copy from this repository (master branch) to overwrite PlatformIO's files. Now, there are no compilation errors, but warnings:
[{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "'int mbed::TimerBase::read_ms() const' is deprecated: Use the Chrono-based elapsed_time method. If integer milliseconds are needed, you can use `duration_cast<milliseconds>(elapsed_time()).count()` [since mbed-os-6.0.0] [-Wdeprecated-declarations]",
"startLineNumber": 51,
"startColumn": 47,
"endLineNumber": 51,
"endColumn": 47
},{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "'int events::EventQueue::call_every(int, F) [with F = void (*)()]' 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]",
"startLineNumber": 71,
"startColumn": 36,
"endLineNumber": 71,
"endColumn": 36
},{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "'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]",
"startLineNumber": 78,
"startColumn": 44,
"endLineNumber": 78,
"endColumn": 44
},{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "'ble::BLE::InstanceID_t ble::BLE::getInstanceID() const' is deprecated: BLE singleton supports one instance. You may create multipleinstances by using the constructor. [since mbed-os-6.3.0] [-Wdeprecated-declarations]",
"startLineNumber": 98,
"startColumn": 25,
"endLineNumber": 98,
"endColumn": 25
},{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "unused variable 'sm' [-Wunused-variable]",
"startLineNumber": 203,
"startColumn": 9,
"endLineNumber": 203,
"endColumn": 9
},{
"resource": "/d:/Documentos/dev/PlatformIO/PruebasChungas/Test1/.pio/libdeps/nano33ble/Mbed BLE HID/src/Mbed_BLE_HID.cpp",
"owner": "cpp",
"severity": 4,
"message": "unused variable 'handle' [-Wunused-variable]",
"startLineNumber": 204,
"startColumn": 8,
"endLineNumber": 204,
"endColumn": 8
}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.