-
-
Notifications
You must be signed in to change notification settings - Fork 283
BLE central Role implementation and peripheral refactor #255
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
Conversation
@sgbihu please read our commit message guidelines and follow them. You have 3 commits here; one of them adds a single line to a file, and the very next one removes that same line.. Can you please remove these two first commits? Additionally, github is unable to show me the whole diff because there are so many files. This will make it difficult for us to review and add line comments. Could you consider breaking this one giant commit into smaller, logical commits? for example, 1 for Serial1 debug interface, 1 for BLE peripheral refactor, 1 for BLE central implementation & example sketches. |
@@ -53,3 +53,21 @@ them to the [support forum](https://forum.arduino.cc/index.php?board=103). | |||
> "How do I use this library?" | |||
|
|||
> "I can't get this example sketch to work. What am I doing wrong?" | |||
|
|||
# Enable debug interface on Serail1 |
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.
Should be Serial1
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.
Change the typo
I'm sorry @sgbihu, I misspoke; the commit message on your large BLE commit is actually fine. So the only things that need to be done here are 1) remove the first two commits, and 2) split each task in the big BLE commit into separate commits. We can still review it, in the meantime, but if you can fix these things before it gets merged we would appreciate it. |
#include <stdarg.h> | ||
#include "UARTClass.h" | ||
|
||
extern "C" void printk(const char *fmt, va_list args); |
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.
Is printk/vsnprintf really needed for BLE central?
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.
Not for central. Only for debug.
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.
I guess I'm just not sure why we need a new function to print formatted strings, when there are already some options for that available. Which specific features of vsnprintf are required to debug BLE Central?
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.
Remove this function and use vsnprintf in cstdio.
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.
Just want debug corelib easier.
a91080e
to
91018b5
Compare
{ | ||
if (NULL == _ble_central_ins) | ||
{ | ||
_ble_central_ins = new BLECentralRole(); |
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.
I think _ble_central_ins
should also be deleted in BLECentralRole::~BLECentralRole
, otherwise that memory will be lost after using BLE
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.
The BLECentralRole and BLEPeripheralRole is a hardware abstract layer for application. So the instance will always exist when start BLE. And this variable is static. No memory leak.
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.
static BLECentralRole* _ble_central_ins;
Well, the pointer is static, but not what it points to. At the end of the day, malloc gets called when you use the new
keyword (see the override in cores/arduino/new.cpp
).
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.
Yes, it call the malloc and get the memory resource. But the stack and Nordic’s code didn’t have API to deregister the BLE profile. And the stack also use the pointer that point to the CurieBLE LIB. If we release those resource, the stack will have wild pointer and we didn't have a API to clean it. So we can't release those resource. Our current design use singleton pattern. Those resource can be managed and never leak.
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.
We also can release those resource. But the BLE can't call begin after call end. I can change the code if you think this is acceptable.
@@ -0,0 +1,129 @@ | |||
/* |
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.
Can you please put some explanatory comments at the top of each example sketch? i.e. what the sketch does and maybe a quick summary of how it works. Look at the existing built-in example sketches for reference.
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.
Add some comment to describe the function.
There is a runtime issue where a peripheral cannot be discovered or not advertising . Please see #258 |
5495297
to
02ffdf0
Compare
#include <CurieIMU.h> | ||
|
||
/* | ||
This sketch example partially implements the standard Bluetooth Low-Energy Battery service. |
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.
Is this comment accurate?
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.
Change the comments.
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.
It looks the same... I'm talking about this line
This sketch example partially implements the standard Bluetooth Low-Energy Battery service
It's the same line from the BatteryMonitor sketch. Can you replace it with something that explains to the user what the sketch is doing? and likewise for the other examples?
|
@calvinatintel . Have you tried using another serial terminal for the LED sketch and then push the LEDCentral after it is running. I find running 2 instances of the IDE for Serial Monitor is problematic. Anyway I will test this again. |
I have not counted but I have also noticed having to hit the reset button more than once and it is not exclusive to the BLE sketches. I am using 1.6.11 |
Hi @calvinatintel and @noelpaz , Can we move to Jira? I create a Jira tickets. https://jira.ndg.intel.com/browse/ATLEDGE-680 Now this issue is fixed. |
That's okay -- I saw the fix for JIRA-680 |
@@ -295,7 +295,7 @@ void BLEPeripheralRole::handleParamUpdated(struct bt_conn *conn, | |||
conn, interval, latency, timeout); | |||
if (_event_handlers[BLEUpdateParam]) | |||
{ | |||
_central.setConnParames(interval, interval, latency, timeout); | |||
_central.setConnectionParameters(interval, interval, latency, timeout); |
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.
@sgbihu -- do we have a test sketch that will test these changes
-Add debug interface on Serial1 -Update BLE stack and need update BLE's FW -Reconstruct the BLE peripheral base on V3 -Implement the BLE Central Role base on V3 -Implement some sketches for new BLE library -Add central read/write example -Add set advertising parameter interface -Add API to allow set up advertising after setup -Add interface to set the device name File description Porting from V3 system/libarc32_arduino101/common/atomic.h system/libarc32_arduino101/common/misc/byteorder.h system/libarc32_arduino101/drivers/atomic_native.c system/libarc32_arduino101/drivers/bluetooth/att.h system/libarc32_arduino101/drivers/bluetooth/bluetooth.h system/libarc32_arduino101/drivers/bluetooth/conn.h system/libarc32_arduino101/drivers/bluetooth/conn_internal.h system/libarc32_arduino101/drivers/bluetooth/gatt.h system/libarc32_arduino101/drivers/bluetooth/hci.h system/libarc32_arduino101/drivers/bluetooth/uuid.h system/libarc32_arduino101/drivers/rpc/rpc.h system/libarc32_arduino101/drivers/rpc/rpc_deserialize.c system/libarc32_arduino101/drivers/rpc/rpc_functions_to_ble_core.h system/libarc32_arduino101/drivers/rpc/rpc_functions_to_quark.h system/libarc32_arduino101/drivers/rpc/rpc_serialize.c system/libarc32_arduino101/framework/include/util/misc.h system/libarc32_arduino101/framework/src/os/panic.c system/libarc32_arduino101/framework/src/services/ble/conn.c system/libarc32_arduino101/framework/src/services/ble/conn_internal.h system/libarc32_arduino101/framework/src/services/ble/dtm_tcmd.c system/libarc32_arduino101/framework/src/services/ble/gap.c system/libarc32_arduino101/framework/src/services/ble/gatt.c system/libarc32_arduino101/framework/src/services/ble/hci_core.h system/libarc32_arduino101/framework/src/services/ble/l2cap.c system/libarc32_arduino101/framework/src/services/ble/l2cap_internal.h system/libarc32_arduino101/framework/src/services/ble/smp.h system/libarc32_arduino101/framework/src/services/ble/smp_null.c system/libarc32_arduino101/framework/src/services/ble/uuid.c system/libarc32_arduino101/framework/src/services/ble_service/ble_service.c system/libarc32_arduino101/framework/src/services/ble_service/ble_service_api.c system/libarc32_arduino101/framework/src/services/ble_service/ble_service_int.h system/libarc32_arduino101/framework/src/services/ble_service/ble_service_internal.h system/libarc32_arduino101/framework/src/services/ble_service/ble_service_utils.c system/libarc32_arduino101/framework/src/services/ble_service/gap_internal.h system/libarc32_arduino101/framework/src/services/ble_service/gatt_internal.h system/libarc32_arduino101/framework/src/services/ble_service/nble_driver.c
293a9cd
to
2171953
Compare
@sgbihu -- For JIRA 685 Janet wanted a comment on BatteryAdvChange sketch example. On the top of the comment. Please add: "This sketch is not paired with a specific central example sketch, but to see how it works you need to use a BLE app on your phone or central device and try connecting when it is either a connectable or not connectable state as displayed in the serial monitor." |
1. Fix Jira 664 demonstrates changing the ADV data 2. Fix Jira 671 Support update connection interval in central/peripheral
ac7eda5
to
1537c0a
Compare
Merging in! |
@calvinatintel @SidLeung @eriknyquist
I'm sorry for I make the old pull request lost when try to reset my local branch. The logs are lost too.