-
Notifications
You must be signed in to change notification settings - Fork 33
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
BleClient Custom settings #62
base: CustomSettings
Are you sure you want to change the base?
Conversation
Some bug fixed related with AdvertisedDeviceCallbacks and templates. #define BLEMIDI_CREATE_INTANCE fixed
fixed template sintaxis of Client
Serial.print changed by debugging verbose. It may be abled using #define MIDIBLECLIENTVERBOSE
Improved IF-syntaxis
Mayor changes in all configuration setup. Create a custom Config Struct for the client, it heritages from regular repo Struct and adds specific settings of the class. All configurations, including onPassRequest function, may be configured in the upper layers of the code, like in main.c
Tabulation indentation fixed after last commit changes and other minor changes in comments
Thanks @RobertoHE what sketch did you use to compile the code? (I get plenty of errors with your ble_client) |
That's true. Example code must use If you change this, the example compiles with errors? |
Yes, but after some re-arranging of the code I get it to compile: #include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_Client_ESP32.h>
//#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>
struct CustomBufferSizeSettings : public BLEMIDI_NAMESPACE::DefaultSettingsClient {
static const size_t MaxBufferSize = 16;
};
BLEMIDI_CREATE_CUSTOM_INSTANCE("Esp32-BLE-MIDI", MIDI, CustomBufferSizeSettings); // Connect to first server found Can you also include the modified client in this PR please? |
Client example code modified. |
Is It possible to merge the pull request? If not, say me what changes it needs. I think that struct settings are better than modifying defines directly in lib. |
Correct, it might be better the use the settings! |
Only the possible changes are related to h2zero/NimBLE-Arduino#473 (comment). If NimBLE base lib has changed, it may a good moment to update this library (not only Client Mode) for use correctly struct settings in all hardware definitions. |
+1, the MIDI library is also about to get a new release, so we can tag along shortly after |
Added after Nimble Lib update. end() updated.
Write directly to .yaml file
@lathoub Please, check the autotest Logs of the project. CustomSettings.ino compiles successfully, but some errors appear in the other examples. In another way, Custom Setting using Struct is finished and tested. |
Check this post: arduino/arduino-cli#765 @lathoub |
DONE. |
Added all configurations options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to define LED-BUILTIN in the examples? (I believe this macro is defined in the device definition)
I am using PlatformIO within VisualStudio Code and this macro is not defined in my case, so I can't compile it. And I have had the same problem with the auto-test script. The protection that I added in the examples is for defining this macro only in the case that is not previously declared. If you have this macro pre-declared, it will override nothing and will use the default value of LED-BUILTIN. |
When using a template instance in two different ways (for example, different settings struct for differents objects), a lot of lines of warning appear due to some variables being unused. Using these lines, those variables are used for doing nothing and the warnings go away.
You got me to reconsider PlatformIO again :-) and ran into
|
Yes, with build_flag you can set any #define in compiling step if compiler doesn't have this #define. The problem (for a beginer with no knowledge about programming who only wants to run the example without editing anything) is that example codes don't compile, it is necessary to edit the code, adding #define LED_BUILTIN X (for arduino IDE) or build_flags = -D LED_BUILTIN=2 (for platformio). In other words, additional steps are necessary for running the example. With those lines, LED_BUILTIN gets a default value in case it is not previously declared. If you set the value using #define or bulid_flags, the new value will overwrite the previous one. In all cases, the examples compile. In my opinion, an example must compile and run autonomily without changes. |
Class changed to new setting struct.
Some warnings appear when compile, but it works fine.
Please, @lathoub , check it before merge.