Implement ble_gatts_value_set()#195
Implement ble_gatts_value_set()#195dangu wants to merge 5 commits intoNordicSemiconductor:masterfrom
Conversation
A Python class BLEGattsValue() is also created to feed sd_ble_gatts_value_set()
jornbh
left a comment
There was a problem hiding this comment.
These changes are missing tests. If you want to add them, you can follow the format of the tests in the tests/ folder.
pc_ble_driver_py/ble_driver.py
Outdated
| return char_md | ||
|
|
||
| class BLEGattsValue(object): | ||
| def __init__(self, value=[0], offset=0): |
There was a problem hiding this comment.
Having lists can as the default parameters to functions can often be risky, since any change the list will persist between function calls. It is often safer to do:
f(arg=None):
if arg == None:
arg = [0]
There was a problem hiding this comment.
Good catch! That was new to me. Updating with None as default parameter.
There was a problem hiding this comment.
Oh, about writing tests: I'm not sure how to write a test involving ble_gatts_value_set() as I need a conn_handle and a handle for it?
Not sure how to create a test for ble_gatts_value_set() using the conn_handle and handle arguments
5ff8ff2 to
ae009cf
Compare
jornbh
left a comment
There was a problem hiding this comment.
Since creating a gatt-database will be so much work, just for a single test, I think it should be fine to skip the test for this one as long as the code looks sound enough.
| def __init__(self, value=None, offset=0): | ||
| if value == None: | ||
| value = [0] |
There was a problem hiding this comment.
What is the reason for why you want the default value to be a list with 0 elements?
Also, do you support the functionality for when p_value is set to NULL(https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/structble__gatts__value__t.html)?
There was a problem hiding this comment.
One version of the underlying c-function can be found at
ble_gatts_value_set
Implement ble_gatts_value_set(). A Python class BLEGattsValue() is also created to feed sd_ble_gatts_value_set()