mirror of https://github.com/labapart/gattlib
parent
531477b941
commit
eca8415fd6
|
@ -548,3 +548,7 @@ int get_handle_from_uuid(gatt_connection_t* connection, const uuid_t* uuid, uint
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gattlib_get_rssi(gatt_connection_t *connection, int16_t *rssi) {
|
||||||
|
return GATTLIB_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
|
@ -1544,3 +1544,15 @@ int gattlib_notification_stop(gatt_connection_t* connection, const uuid_t* uuid)
|
||||||
return GATTLIB_SUCCESS;
|
return GATTLIB_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gattlib_get_rssi(gatt_connection_t *connection, int16_t *rssi) {
|
||||||
|
gattlib_context_t* conn_context = connection->context;
|
||||||
|
|
||||||
|
if (rssi == NULL) {
|
||||||
|
return GATTLIB_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
*rssi = org_bluez_device1_get_rssi(conn_context->device);
|
||||||
|
|
||||||
|
return GATTLIB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -88,3 +88,7 @@ gattlib_register_notification.argtypes = [c_void_p, py_object, py_object]
|
||||||
# void gattlib_register_on_disconnect_python(gatt_connection_t *connection, PyObject *handler, PyObject *user_data)
|
# void gattlib_register_on_disconnect_python(gatt_connection_t *connection, PyObject *handler, PyObject *user_data)
|
||||||
gattlib_register_on_disconnect = gattlib.gattlib_register_on_disconnect_python
|
gattlib_register_on_disconnect = gattlib.gattlib_register_on_disconnect_python
|
||||||
gattlib_register_on_disconnect.argtypes = [c_void_p, py_object, py_object]
|
gattlib_register_on_disconnect.argtypes = [c_void_p, py_object, py_object]
|
||||||
|
|
||||||
|
# int gattlib_get_rssi(gatt_connection_t *connection, int16_t *rssi)
|
||||||
|
gattlib_get_rssi = gattlib.gattlib_get_rssi
|
||||||
|
gattlib_get_rssi.argtypes = [c_void_p, POINTER(c_int16)]
|
||||||
|
|
|
@ -53,6 +53,13 @@ class Device:
|
||||||
if self._connection == 0:
|
if self._connection == 0:
|
||||||
raise DeviceError()
|
raise DeviceError()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rssi(self):
|
||||||
|
_rssi = c_int16(0)
|
||||||
|
ret = gattlib_get_rssi(self._connection, byref(_rssi))
|
||||||
|
handle_return(ret)
|
||||||
|
return _rssi
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_disconnection(user_data):
|
def on_disconnection(user_data):
|
||||||
this = user_data
|
this = user_data
|
||||||
|
|
|
@ -268,6 +268,16 @@ int gattlib_notification_stop(gatt_connection_t* connection, const uuid_t* uuid)
|
||||||
void gattlib_register_notification(gatt_connection_t* connection, gattlib_event_handler_t notification_handler, void* user_data);
|
void gattlib_register_notification(gatt_connection_t* connection, gattlib_event_handler_t notification_handler, void* user_data);
|
||||||
void gattlib_register_indication(gatt_connection_t* connection, gattlib_event_handler_t indication_handler, void* user_data);
|
void gattlib_register_indication(gatt_connection_t* connection, gattlib_event_handler_t indication_handler, void* user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to retrieve RSSI from a GATT connection
|
||||||
|
*
|
||||||
|
* @param connection Active GATT connection
|
||||||
|
* @param rssi is the Received Signal Strength Indicator of the remote device
|
||||||
|
*
|
||||||
|
* @return GATTLIB_SUCCESS on success or GATTLIB_* error code
|
||||||
|
*/
|
||||||
|
int gattlib_get_rssi(gatt_connection_t *connection, int16_t *rssi);
|
||||||
|
|
||||||
int gattlib_uuid_to_string(const uuid_t *uuid, char *str, size_t n);
|
int gattlib_uuid_to_string(const uuid_t *uuid, char *str, size_t n);
|
||||||
int gattlib_string_to_uuid(const char *str, size_t n, uuid_t *uuid);
|
int gattlib_string_to_uuid(const char *str, size_t n, uuid_t *uuid);
|
||||||
int gattlib_uuid_cmp(const uuid_t *uuid1, const uuid_t *uuid2);
|
int gattlib_uuid_cmp(const uuid_t *uuid1, const uuid_t *uuid2);
|
||||||
|
|
Loading…
Reference in New Issue