You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/01/15 19:45:55 UTC
[GitHub] aditihilbert closed pull request #373: automated asf-site build
aditihilbert closed pull request #373: automated asf-site build
URL: https://github.com/apache/mynewt-site/pull/373
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/master/mkdocs/search_index.json b/master/mkdocs/search_index.json
index 301080042d..3417b40bb1 100644
--- a/master/mkdocs/search_index.json
+++ b/master/mkdocs/search_index.json
@@ -1377,7 +1377,7 @@
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/",
- "text": "BLE Peripheral Project\n\n\nService Registration\n\n\n\n\nAttribute Set\n\n\nThe NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code.\n\n\nbleprph\n uses a single attribute table located in the \ngatt_svr.c\n file,\nso let's take a look at that now. The attribute table is called\n\ngatt_svr_svcs\n; here are the first several lines from this table:\n\n\n\n\nstatic\n \nconst\n \nstruct\n \nble_gatt_svc_def\n \ngatt_svr_svcs\n[] \n=\n {\n {\n \n/*** Service: GAP. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_SVC_UU
ID16\n),\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Device Name. */\n\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_CHR_UUID16_DEVICE_NAME\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_gap\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Appearance. */\n\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_CHR_UUID16_APPEARANCE\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_gap\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n// [...]\n\n\n\n\n\n\n\n\nAs you can see, the table is an array of service definitions (\n\nstruct ble_gatt_svc_def\n). This code excerpt contains a small part of the\n\nGAP service\n. The GAP service exposes generic information about a device,\nsuch as its name and appearance. Support for the
GAP service is mandatory for\nall BLE peripherals. Let's now consider the contents of this table in more\ndetail.\n\n\nA service definition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\ntype\n\n\nSpecifies whether this is a primary or secondary service.\n\n\nSecondary services are not very common. When in doubt, specify \nBLE_GATT_SVC_TYPE_PRIMARY\n for new services.\n\n\n\n\n\n\nuuid128\n\n\nThe 128-bit UUID of this service.\n\n\nIf the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the \nBLE_UUID16()\n macro.\n\n\n\n\n\n\ncharacteristics\n\n\nThe array of characteristics that belong to this service.\n\n\n\n\n\n\n\n\n\n\n\n\nA service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nuuid12
8\n\n\nThe 128-bit UUID of this characteristic.\n\n\nIf the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the \nBLE_UUID16()\n macro.\n\n\n\n\n\n\naccess_cb\n\n\nA callback function that gets executed whenever a peer device accesses this characteristic.\n\n\nFor reads:\n this function generates the value that gets sent back to the peer.\nFor writes:\n this function receives the written value as an argument.\n\n\n\n\n\n\nflags\n\n\nIndicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation.\n\n\nThe full list of flags can be found under \nble_gatt_chr_flags\n in \nnet/nimble/host/include/host/ble_gatt.h\n.\n\n\n\n\n\n\n\n\nThe access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section:\n\nBLE Peripheral - Characteristic Access\n.\n\n\nThe service definition array and each characte
ristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array.\n\n\n\n\n {\n \n/*** Alert Notification Service. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_SVC_ALERT_UUID\n),\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_NEW_ALERT\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_NOTIFY\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_SUP_UNR_AL
ERT_CAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_UNR_ALERT_STAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_NOTIFY\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_ALERT_NOT_CTRL_PT\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_WRITE\n,\n }, {\n\n \n0\n, \n/* No more characteristics in this service. */\n\n\n } },\n },\n\n {\n\n \n0\n, \n/* No more services. */\n\n\n },\n\n\n\n\n\n\n\nRegistration function\n\n\nAfter you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:\n\n\nint\n\n\nble_gatts_register_svcs\n(\nconst\n \nstru
ct\n \nble_gatt_svc_def\n \n*svcs\n,\n \nble_gatt_register_fn\n \n*cb\n, \nvoid\n \n*cb_arg\n)\n\n\n\n\n\nThe function parameters are documented below.\n\n\n\n\n\n\n\n\nParameter\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nsvcs\n\n\nThe table of services to register.\n\n\n\n\n\n\n\n\ncb\n\n\nA callback that gets executed each time a service, characteristic, or descriptor is registered.\n\n\nOptional; pass NULL if you don't want to be notified.\n\n\n\n\n\n\ncb_arg\n\n\nAn argument that gets passed to the callback function on each invocation.\n\n\nOptional; pass NULL if there is no callback or if you don't need a special argument.\n\n\n\n\n\n\n\n\nThe \nble_gatts_register_svcs()\n function returns 0 on success, or a\n\nBLE_HS_E[...]\n error code on failure.\n\n\nMore detailed information about the registration callback function can be found\nin the \nBLE User Guide\n (TBD).\n\n\nThe \nbleprph\n app registers its services as follows:\n\n\n \nrc\n \n=\n \nble_
gatts_register_svcs\n(\ngatt_svr_svcs\n, \ngatt_svr_register_cb\n, \nNULL\n);\n \nassert\n(\nrc\n \n==\n \n0\n);\n\n\n\n\n\n\n\nDescriptors and Included Services\n\n\nYour peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the \nBLE User Guide\n.",
+ "text": "BLE Peripheral Project\n\n\nService Registration\n\n\n\n\nAttribute Set\n\n\nThe NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code.\n\n\nbleprph\n uses a single attribute table located in the \ngatt_svr.c\n file,\nso let's take a look at that now. The attribute table is called\n\ngatt_svr_svcs\n; here are the first several lines from this table:\n\n\n\n\nstatic\n \nconst\n \nstruct\n \nble_gatt_svc_def\n \ngatt_svr_svcs\n[] \n=\n {\n {\n \n/*** Service: Security test. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid\n \n=\n \ngatt_svr_svc_sec_test_uuid\n.\nu\n,\n .\
ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Random number generator. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_rand_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Static value. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_static_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n \n// [...]\n\n\n\n\n\n\n\n\nAs you can see, the table is an array of service definitions (\n\nstruct ble_gatt_svc_def\n). Let's now consider the contents of this table in more\ndetail.\n\n\nA service definition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\ntype\n\n\nSpecifies whether this is a primary or secondary service.\n\n\nSecondary serv
ices are not very common. When in doubt, specify \nBLE_GATT_SVC_TYPE_PRIMARY\n for new services.\n\n\n\n\n\n\nuuid\n\n\nThe UUID of this characteristic.\n\n\nThis field accepts a pointer to a variable of type \nble_uuid_t\n. You could directly use the \nBLE_UUID16_DECLARE()\n macro or to pass a pointer to a \nble_uuid16_t\n variable you could type \nuuid_variable.u\n\n\n\n\n\n\ncharacteristics\n\n\nThe array of characteristics that belong to this service.\n\n\n\n\n\n\n\n\n\n\n\n\nA service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nuuid\n\n\nThe UUID of this characteristic.\n\n\nThis field accepts a pointer to a variable of type \nble_uuid_t\n. You could directly use the \nBLE_UUID16_DECLARE()\n macro or to pass a pointer to a \nble_uuid16_t\n variable you could type \nuuid_vari
able.u\n\n\n\n\n\n\naccess_cb\n\n\nA callback function that gets executed whenever a peer device accesses this characteristic.\n\n\nFor reads:\n this function generates the value that gets sent back to the peer.\nFor writes:\n this function receives the written value as an argument.\n\n\n\n\n\n\nflags\n\n\nIndicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation.\n\n\nThe full list of flags can be found under \nble_gatt_chr_flags\n in \nnet/nimble/host/include/host/ble_gatt.h\n.\n\n\n\n\n\n\n\n\nThe access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section:\n\nBLE Peripheral - Characteristic Access\n.\n\n\nThe service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for
the\ncharacteristic array and service array.\n\n\n\n\n {\n \n/*** Service: Security test. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid\n \n=\n \ngatt_svr_svc_sec_test_uuid\n.\nu\n,\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Random number generator. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_rand_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Static value. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_static_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n\n \n0\n, \n/* No more characteristics in this service. */\n\n\n } },\n },\n\n {\n\n \n0\n, \n/* No more services. */\n\n\n
},\n\n\n\n\n\n\n\nRegistration function\n\n\nAfter you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:\n\n\nint\n\n\nble_gatts_add_svcs\n(\nconst\n \nstruct\n \nble_gatt_svc_def\n \n*svcs\n)\n\n\n\n\n\nThe function parameters are documented below.\n\n\n\n\n\n\n\n\nParameter\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nsvcs\n\n\nAn array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0.\n\n\n\n\n\n\n\n\n\n\nThe \nble_gatts_register_svcs()\n function returns 0 on success, or a\n\nBLE_HS_E[...]\n error code on failure.\n\n\nThe \nbleprph\n app registers its services as follows:\n\n\n \nrc\n \n=\n \nble_gatts_add_svcs\n(\ngatt_svr_svcs\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \nrc\n;\n }\n\n\n\n\n\nMore detailed information about the registration function can be found\nin the BLE User Guide: \nble_gatts_add
_svcs\n.\n\n\n\n\nRegistration callback function\n\n\nIt is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute:\n\n\nble_hs_cfg\n.\ngatts_register_cb\n \n=\n \ngatt_svr_register_cb\n;\n\n\n\n\n\nIn the above example \ngatt_svr_register_cb\n is the function that will be called. This line can be found in \nbleprph\n's \nmain.c\n file\n\n\nMore detailed information about the registration callback function can be found\nin the \nBLE User Guide\n (TBD).\n\n\n\n\nDescriptors and Included Services\n\n\nYour peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the \nBLE User Guide\n.",
"title": "Service Registration"
},
{
@@ -1392,14 +1392,19 @@
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#attribute-set",
- "text": "The NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code. bleprph uses a single attribute table located in the gatt_svr.c file,\nso let's take a look at that now. The attribute table is called gatt_svr_svcs ; here are the first several lines from this table: static const struct ble_gatt_svc_def gatt_svr_svcs [] = {\n {\n /*** Service: GAP. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid128 = BLE_UUID16 ( BLE_GAP_SVC_UUID16 ),\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Device
Name. */ \n . uuid128 = BLE_UUID16 ( BLE_GAP_CHR_UUID16_DEVICE_NAME ),\n . access_cb = gatt_svr_chr_access_gap ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Appearance. */ \n . uuid128 = BLE_UUID16 ( BLE_GAP_CHR_UUID16_APPEARANCE ),\n . access_cb = gatt_svr_chr_access_gap ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n // [...] As you can see, the table is an array of service definitions ( struct ble_gatt_svc_def ). This code excerpt contains a small part of the GAP service . The GAP service exposes generic information about a device,\nsuch as its name and appearance. Support for the GAP service is mandatory for\nall BLE peripherals. Let's now consider the contents of this table in more\ndetail. A service definition consists of the following fields: Field Meaning Notes
type Specifies whether this is a primary or secondary service. Secondary services are not very common. When in doubt, specify BLE_GATT_SVC_TYPE_PRIMARY for new services. uuid128 The 128-bit UUID of this service. If the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the BLE_UUID16() macro. characteristics The array of characteristics that belong to this service. A service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields: Field Meaning Notes uuid128 The 128-bit UUID of this characteristic. If the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the BLE_UUID16() macro. access_cb A callback function that gets executed whenever a peer device accesses this characteristic. For reads: this function generates the value that gets sent
back to the peer. For writes: this function receives the written value as an argument. flags Indicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation. The full list of flags can be found under ble_gatt_chr_flags in net/nimble/host/include/host/ble_gatt.h . The access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section: BLE Peripheral - Characteristic Access . The service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array. {\n /*** Alert Notification Service. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid128 = BLE_UUID16 ( GATT_SVR_SVC_ALERT_UUID ),\n . characteri
stics = ( struct ble_gatt_chr_def []) { {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_NEW_ALERT ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_NOTIFY ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_UNR_ALERT_STAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_NOTIFY ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_ALERT_NOT_CTRL_PT ),\n . access_cb = gatt_svr_chr_access_alert ,\n .
flags = BLE_GATT_CHR_F_WRITE ,\n }, { 0 , /* No more characteristics in this service. */ } },\n },\n\n { 0 , /* No more services. */ },",
+ "text": "The NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code. bleprph uses a single attribute table located in the gatt_svr.c file,\nso let's take a look at that now. The attribute table is called gatt_svr_svcs ; here are the first several lines from this table: static const struct ble_gatt_svc_def gatt_svr_svcs [] = {\n {\n /*** Service: Security test. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid = gatt_svr_svc_sec_test_uuid . u ,\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Random number generator. */ \n
. uuid = gatt_svr_chr_sec_test_rand_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Static value. */ \n . uuid = gatt_svr_chr_sec_test_static_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n // [...] As you can see, the table is an array of service definitions ( struct ble_gatt_svc_def ). Let's now consider the contents of this table in more\ndetail. A service definition consists of the following fields: Field Meaning Notes type Specifies whether this is a primary or secondary service. Secondary services are not very common. When in doubt, specify BLE_GATT_SVC_TYPE_PRIMARY for new services. uuid The UUID of this characteristic. This field accepts a pointer to a variable of type ble_uuid_t . You could directly use the BLE_UUID16
_DECLARE() macro or to pass a pointer to a ble_uuid16_t variable you could type uuid_variable.u characteristics The array of characteristics that belong to this service. A service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields: Field Meaning Notes uuid The UUID of this characteristic. This field accepts a pointer to a variable of type ble_uuid_t . You could directly use the BLE_UUID16_DECLARE() macro or to pass a pointer to a ble_uuid16_t variable you could type uuid_variable.u access_cb A callback function that gets executed whenever a peer device accesses this characteristic. For reads: this function generates the value that gets sent back to the peer. For writes: this function receives the written value as an argument. flags Indicates which operations are permitted for this characteristic. The NimBLE sta
ck responds negatively when a peer attempts an unsupported operation. The full list of flags can be found under ble_gatt_chr_flags in net/nimble/host/include/host/ble_gatt.h . The access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section: BLE Peripheral - Characteristic Access . The service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array. {\n /*** Service: Security test. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid = gatt_svr_svc_sec_test_uuid . u ,\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Random number generator. */ \n . uuid = gatt_svr_chr_sec_test_rand_uuid . u ,\n . acces
s_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Static value. */ \n . uuid = gatt_svr_chr_sec_test_static_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, { 0 , /* No more characteristics in this service. */ } },\n },\n\n { 0 , /* No more services. */ },",
"title": "Attribute Set"
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#registration-function",
- "text": "After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function: int ble_gatts_register_svcs ( const struct ble_gatt_svc_def *svcs ,\n ble_gatt_register_fn *cb , void *cb_arg ) The function parameters are documented below. Parameter Meaning Notes svcs The table of services to register. cb A callback that gets executed each time a service, characteristic, or descriptor is registered. Optional; pass NULL if you don't want to be notified. cb_arg An argument that gets passed to the callback function on each invocation. Optional; pass NULL if there is no callback or if you don't need a special argument. The ble_gatts_register_svcs() function returns 0 on success, or a BLE_HS_E[...] error code on failure. More detailed information about the registration callback function can be found\nin the BLE User Guide (TBD). The
bleprph app registers its services as follows: rc = ble_gatts_register_svcs ( gatt_svr_svcs , gatt_svr_register_cb , NULL );\n assert ( rc == 0 );",
+ "text": "After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function: int ble_gatts_add_svcs ( const struct ble_gatt_svc_def *svcs ) The function parameters are documented below. Parameter Meaning Notes svcs An array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0. The ble_gatts_register_svcs() function returns 0 on success, or a BLE_HS_E[...] error code on failure. The bleprph app registers its services as follows: rc = ble_gatts_add_svcs ( gatt_svr_svcs );\n if ( rc != 0 ) {\n return rc ;\n } More detailed information about the registration function can be found\nin the BLE User Guide: ble_gatts_add_svcs .",
"title": "Registration function"
},
+ {
+ "location": "/os/tutorials/bleprph/bleprph-svc-reg/#registration-callback-function",
+ "text": "It is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute: ble_hs_cfg . gatts_register_cb = gatt_svr_register_cb ; In the above example gatt_svr_register_cb is the function that will be called. This line can be found in bleprph 's main.c file More detailed information about the registration callback function can be found\nin the BLE User Guide (TBD).",
+ "title": "Registration callback function"
+ },
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#descriptors-and-included-services",
"text": "Your peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the BLE User Guide .",
diff --git a/master/os/tutorials/bleprph/bleprph-svc-reg/index.html b/master/os/tutorials/bleprph/bleprph-svc-reg/index.html
index 0f772da123..670e50e799 100644
--- a/master/os/tutorials/bleprph/bleprph-svc-reg/index.html
+++ b/master/os/tutorials/bleprph/bleprph-svc-reg/index.html
@@ -598,30 +598,26 @@ <h4 id="attribute-set">Attribute Set</h4>
<p><br></p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #A90D91">static</span> <span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">gatt_svr_svcs</span>[] <span style="color: #000000">=</span> {
{
- <span style="color: #177500">/*** Service: GAP. */</span>
- .<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_SVC_UUID16</span>),
- .<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
- <span style="color: #177500">/*** Characteristic: Device Name. */</span>
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_CHR_UUID16_DEVICE_NAME</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_gap</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
- }, {
- <span style="color: #177500">/*** Characteristic: Appearance. */</span>
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_CHR_UUID16_APPEARANCE</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_gap</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
+ <span style="color: #177500">/*** Service: Security test. */</span>
+ .<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_svc_sec_test_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
+ <span style="color: #177500">/*** Characteristic: Random number generator. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_rand_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
+ .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
+ <span style="color: #177500">/*** Characteristic: Static value. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_static_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
+ .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
<span style="color: #177500">// [...]</span>
</pre></div>
<p><br></p>
<p>As you can see, the table is an array of service definitions (
-<code>struct ble_gatt_svc_def</code>). This code excerpt contains a small part of the
-<em>GAP service</em>. The GAP service exposes generic information about a device,
-such as its name and appearance. Support for the GAP service is mandatory for
-all BLE peripherals. Let's now consider the contents of this table in more
+<code>struct ble_gatt_svc_def</code>). Let's now consider the contents of this table in more
detail.</p>
<p>A service definition consists of the following fields:</p>
<table>
@@ -639,9 +635,9 @@ <h4 id="attribute-set">Attribute Set</h4>
<td>Secondary services are not very common. When in doubt, specify <em>BLE_GATT_SVC_TYPE_PRIMARY</em> for new services.</td>
</tr>
<tr>
-<td>uuid128</td>
-<td>The 128-bit UUID of this service.</td>
-<td>If the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the <code>BLE_UUID16()</code> macro.</td>
+<td>uuid</td>
+<td>The UUID of this characteristic.</td>
+<td>This field accepts a pointer to a variable of type <code>ble_uuid_t</code>. You could directly use the <code>BLE_UUID16_DECLARE()</code> macro or to pass a pointer to a <code>ble_uuid16_t</code> variable you could type <code>&uuid_variable.u</code></td>
</tr>
<tr>
<td>characteristics</td>
@@ -652,7 +648,7 @@ <h4 id="attribute-set">Attribute Set</h4>
</table>
<p><br></p>
<p>A service is little more than a container of characteristics; the
-characteristics themselves are where the real action happens. A characteristic
+characteristics themselves are where the real action happens. A characteristic
definition consists of the following fields:</p>
<table>
<thead>
@@ -664,9 +660,9 @@ <h4 id="attribute-set">Attribute Set</h4>
</thead>
<tbody>
<tr>
-<td>uuid128</td>
-<td>The 128-bit UUID of this characteristic.</td>
-<td>If the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the <code>BLE_UUID16()</code> macro.</td>
+<td>uuid</td>
+<td>The UUID of this characteristic.</td>
+<td>This field accepts a pointer to a variable of type <code>ble_uuid_t</code>. You could directly use the <code>BLE_UUID16_DECLARE()</code> macro or to pass a pointer to a <code>ble_uuid16_t</code> variable you could type <code>&uuid_variable.u</code></td>
</tr>
<tr>
<td>access_cb</td>
@@ -680,39 +676,29 @@ <h4 id="attribute-set">Attribute Set</h4>
</tr>
</tbody>
</table>
-<p>The access callback is what implements the characteristic's behavior. Access
+<p>The access callback is what implements the characteristic's behavior. Access
callbacks are described in detail in the next section:
<a href="../bleprph-chr-access/">BLE Peripheral - Characteristic Access</a>.</p>
<p>The service definition array and each characteristic definition array is
-terminated with an empty entry, represented with a 0. The below code listing
+terminated with an empty entry, represented with a 0. The below code listing
shows the last service in the array, including terminating zeros for the
characteristic array and service array.</p>
<p><br></p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> {
- <span style="color: #177500">/*** Alert Notification Service. */</span>
+ <span style="color: #177500">/*** Service: Security test. */</span>
.<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_SVC_ALERT_UUID</span>),
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_svc_sec_test_uuid</span>.<span style="color: #000000">u</span>,
.<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
+ <span style="color: #177500">/*** Characteristic: Random number generator. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_rand_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
.<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_NEW_ALERT</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_NOTIFY</span>,
- }, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
+ <span style="color: #177500">/*** Characteristic: Static value. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_static_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
.<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_UNR_ALERT_STAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_NOTIFY</span>,
- }, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_ALERT_NOT_CTRL_PT</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_WRITE</span>,
- }, {
<span style="background-color: #ffffcc"> <span style="color: #1C01CE">0</span>, <span style="color: #177500">/* No more characteristics in this service. */</span>
</span> } },
},
@@ -727,8 +713,7 @@ <h4 id="attribute-set">Attribute Set</h4>
<h4 id="registration-function">Registration function</h4>
<p>After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:</p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #A90D91">int</span>
-<span style="color: #000000">ble_gatts_register_svcs</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">*svcs</span>,
- <span style="color: #000000">ble_gatt_register_fn</span> <span style="color: #000000">*cb</span>, <span style="color: #A90D91">void</span> <span style="color: #000000">*cb_arg</span>)
+<span style="color: #000000">ble_gatts_add_svcs</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">*svcs</span>)
</pre></div>
@@ -744,31 +729,33 @@ <h4 id="registration-function">Registration function</h4>
<tbody>
<tr>
<td>svcs</td>
-<td>The table of services to register.</td>
+<td>An array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0.</td>
<td></td>
</tr>
-<tr>
-<td>cb</td>
-<td>A callback that gets executed each time a service, characteristic, or descriptor is registered.</td>
-<td>Optional; pass NULL if you don't want to be notified.</td>
-</tr>
-<tr>
-<td>cb_arg</td>
-<td>An argument that gets passed to the callback function on each invocation.</td>
-<td>Optional; pass NULL if there is no callback or if you don't need a special argument.</td>
-</tr>
</tbody>
</table>
<p>The <code>ble_gatts_register_svcs()</code> function returns 0 on success, or a
<em>BLE_HS_E[...]</em> error code on failure.</p>
-<p>More detailed information about the registration callback function can be found
-in the <a href="../../../../network/ble/ble_intro/">BLE User Guide</a> (TBD).</p>
<p>The <em>bleprph</em> app registers its services as follows:</p>
-<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">ble_gatts_register_svcs</span>(<span style="color: #000000">gatt_svr_svcs</span>, <span style="color: #000000">gatt_svr_register_cb</span>, <span style="color: #A90D91">NULL</span>);
- <span style="color: #000000">assert</span>(<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #1C01CE">0</span>);
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">ble_gatts_add_svcs</span>(<span style="color: #000000">gatt_svr_svcs</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">rc</span>;
+ }
+</pre></div>
+
+
+<p>More detailed information about the registration function can be found
+in the BLE User Guide: <a href="../../../../network/ble/ble_hs/ble_gatts/functions/ble_gatts_add_svcs/">ble_gatts_add_svcs</a>.</p>
+<p><br></p>
+<h4 id="registration-callback-function">Registration callback function</h4>
+<p>It is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute:</p>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #000000">ble_hs_cfg</span>.<span style="color: #000000">gatts_register_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_register_cb</span>;
</pre></div>
+<p>In the above example <code>gatt_svr_register_cb</code> is the function that will be called. This line can be found in <em>bleprph</em>'s <code>main.c</code> file</p>
+<p>More detailed information about the registration callback function can be found
+in the <a href="../../../../network/ble/ble_intro/">BLE User Guide</a> (TBD).</p>
<p><br></p>
<h4 id="descriptors-and-included-services">Descriptors and Included Services</h4>
<p>Your peripheral can also expose descriptors and included services. These are
diff --git a/mkdocs/search_index.json b/mkdocs/search_index.json
index 301080042d..3417b40bb1 100644
--- a/mkdocs/search_index.json
+++ b/mkdocs/search_index.json
@@ -1377,7 +1377,7 @@
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/",
- "text": "BLE Peripheral Project\n\n\nService Registration\n\n\n\n\nAttribute Set\n\n\nThe NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code.\n\n\nbleprph\n uses a single attribute table located in the \ngatt_svr.c\n file,\nso let's take a look at that now. The attribute table is called\n\ngatt_svr_svcs\n; here are the first several lines from this table:\n\n\n\n\nstatic\n \nconst\n \nstruct\n \nble_gatt_svc_def\n \ngatt_svr_svcs\n[] \n=\n {\n {\n \n/*** Service: GAP. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_SVC_UU
ID16\n),\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Device Name. */\n\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_CHR_UUID16_DEVICE_NAME\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_gap\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Appearance. */\n\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nBLE_GAP_CHR_UUID16_APPEARANCE\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_gap\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n// [...]\n\n\n\n\n\n\n\n\nAs you can see, the table is an array of service definitions (\n\nstruct ble_gatt_svc_def\n). This code excerpt contains a small part of the\n\nGAP service\n. The GAP service exposes generic information about a device,\nsuch as its name and appearance. Support for the
GAP service is mandatory for\nall BLE peripherals. Let's now consider the contents of this table in more\ndetail.\n\n\nA service definition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\ntype\n\n\nSpecifies whether this is a primary or secondary service.\n\n\nSecondary services are not very common. When in doubt, specify \nBLE_GATT_SVC_TYPE_PRIMARY\n for new services.\n\n\n\n\n\n\nuuid128\n\n\nThe 128-bit UUID of this service.\n\n\nIf the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the \nBLE_UUID16()\n macro.\n\n\n\n\n\n\ncharacteristics\n\n\nThe array of characteristics that belong to this service.\n\n\n\n\n\n\n\n\n\n\n\n\nA service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nuuid12
8\n\n\nThe 128-bit UUID of this characteristic.\n\n\nIf the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the \nBLE_UUID16()\n macro.\n\n\n\n\n\n\naccess_cb\n\n\nA callback function that gets executed whenever a peer device accesses this characteristic.\n\n\nFor reads:\n this function generates the value that gets sent back to the peer.\nFor writes:\n this function receives the written value as an argument.\n\n\n\n\n\n\nflags\n\n\nIndicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation.\n\n\nThe full list of flags can be found under \nble_gatt_chr_flags\n in \nnet/nimble/host/include/host/ble_gatt.h\n.\n\n\n\n\n\n\n\n\nThe access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section:\n\nBLE Peripheral - Characteristic Access\n.\n\n\nThe service definition array and each characte
ristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array.\n\n\n\n\n {\n \n/*** Alert Notification Service. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_SVC_ALERT_UUID\n),\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_NEW_ALERT\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_NOTIFY\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_SUP_UNR_AL
ERT_CAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_UNR_ALERT_STAT_UUID\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_NOTIFY\n,\n }, {\n .\nuuid128\n \n=\n \nBLE_UUID16\n(\nGATT_SVR_CHR_ALERT_NOT_CTRL_PT\n),\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_alert\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_WRITE\n,\n }, {\n\n \n0\n, \n/* No more characteristics in this service. */\n\n\n } },\n },\n\n {\n\n \n0\n, \n/* No more services. */\n\n\n },\n\n\n\n\n\n\n\nRegistration function\n\n\nAfter you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:\n\n\nint\n\n\nble_gatts_register_svcs\n(\nconst\n \nstru
ct\n \nble_gatt_svc_def\n \n*svcs\n,\n \nble_gatt_register_fn\n \n*cb\n, \nvoid\n \n*cb_arg\n)\n\n\n\n\n\nThe function parameters are documented below.\n\n\n\n\n\n\n\n\nParameter\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nsvcs\n\n\nThe table of services to register.\n\n\n\n\n\n\n\n\ncb\n\n\nA callback that gets executed each time a service, characteristic, or descriptor is registered.\n\n\nOptional; pass NULL if you don't want to be notified.\n\n\n\n\n\n\ncb_arg\n\n\nAn argument that gets passed to the callback function on each invocation.\n\n\nOptional; pass NULL if there is no callback or if you don't need a special argument.\n\n\n\n\n\n\n\n\nThe \nble_gatts_register_svcs()\n function returns 0 on success, or a\n\nBLE_HS_E[...]\n error code on failure.\n\n\nMore detailed information about the registration callback function can be found\nin the \nBLE User Guide\n (TBD).\n\n\nThe \nbleprph\n app registers its services as follows:\n\n\n \nrc\n \n=\n \nble_
gatts_register_svcs\n(\ngatt_svr_svcs\n, \ngatt_svr_register_cb\n, \nNULL\n);\n \nassert\n(\nrc\n \n==\n \n0\n);\n\n\n\n\n\n\n\nDescriptors and Included Services\n\n\nYour peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the \nBLE User Guide\n.",
+ "text": "BLE Peripheral Project\n\n\nService Registration\n\n\n\n\nAttribute Set\n\n\nThe NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code.\n\n\nbleprph\n uses a single attribute table located in the \ngatt_svr.c\n file,\nso let's take a look at that now. The attribute table is called\n\ngatt_svr_svcs\n; here are the first several lines from this table:\n\n\n\n\nstatic\n \nconst\n \nstruct\n \nble_gatt_svc_def\n \ngatt_svr_svcs\n[] \n=\n {\n {\n \n/*** Service: Security test. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid\n \n=\n \ngatt_svr_svc_sec_test_uuid\n.\nu\n,\n .\
ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Random number generator. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_rand_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Static value. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_static_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n \n// [...]\n\n\n\n\n\n\n\n\nAs you can see, the table is an array of service definitions (\n\nstruct ble_gatt_svc_def\n). Let's now consider the contents of this table in more\ndetail.\n\n\nA service definition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\ntype\n\n\nSpecifies whether this is a primary or secondary service.\n\n\nSecondary serv
ices are not very common. When in doubt, specify \nBLE_GATT_SVC_TYPE_PRIMARY\n for new services.\n\n\n\n\n\n\nuuid\n\n\nThe UUID of this characteristic.\n\n\nThis field accepts a pointer to a variable of type \nble_uuid_t\n. You could directly use the \nBLE_UUID16_DECLARE()\n macro or to pass a pointer to a \nble_uuid16_t\n variable you could type \nuuid_variable.u\n\n\n\n\n\n\ncharacteristics\n\n\nThe array of characteristics that belong to this service.\n\n\n\n\n\n\n\n\n\n\n\n\nA service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields:\n\n\n\n\n\n\n\n\nField\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nuuid\n\n\nThe UUID of this characteristic.\n\n\nThis field accepts a pointer to a variable of type \nble_uuid_t\n. You could directly use the \nBLE_UUID16_DECLARE()\n macro or to pass a pointer to a \nble_uuid16_t\n variable you could type \nuuid_vari
able.u\n\n\n\n\n\n\naccess_cb\n\n\nA callback function that gets executed whenever a peer device accesses this characteristic.\n\n\nFor reads:\n this function generates the value that gets sent back to the peer.\nFor writes:\n this function receives the written value as an argument.\n\n\n\n\n\n\nflags\n\n\nIndicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation.\n\n\nThe full list of flags can be found under \nble_gatt_chr_flags\n in \nnet/nimble/host/include/host/ble_gatt.h\n.\n\n\n\n\n\n\n\n\nThe access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section:\n\nBLE Peripheral - Characteristic Access\n.\n\n\nThe service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for
the\ncharacteristic array and service array.\n\n\n\n\n {\n \n/*** Service: Security test. */\n\n .\ntype\n \n=\n \nBLE_GATT_SVC_TYPE_PRIMARY\n,\n .\nuuid\n \n=\n \ngatt_svr_svc_sec_test_uuid\n.\nu\n,\n .\ncharacteristics\n \n=\n (\nstruct\n \nble_gatt_chr_def\n[]) { {\n \n/*** Characteristic: Random number generator. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_rand_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n \n/*** Characteristic: Static value. */\n\n .\nuuid\n \n=\n \ngatt_svr_chr_sec_test_static_uuid\n.\nu\n,\n .\naccess_cb\n \n=\n \ngatt_svr_chr_access_sec_test\n,\n .\nflags\n \n=\n \nBLE_GATT_CHR_F_READ\n,\n }, {\n\n \n0\n, \n/* No more characteristics in this service. */\n\n\n } },\n },\n\n {\n\n \n0\n, \n/* No more services. */\n\n\n
},\n\n\n\n\n\n\n\nRegistration function\n\n\nAfter you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:\n\n\nint\n\n\nble_gatts_add_svcs\n(\nconst\n \nstruct\n \nble_gatt_svc_def\n \n*svcs\n)\n\n\n\n\n\nThe function parameters are documented below.\n\n\n\n\n\n\n\n\nParameter\n\n\nMeaning\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nsvcs\n\n\nAn array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0.\n\n\n\n\n\n\n\n\n\n\nThe \nble_gatts_register_svcs()\n function returns 0 on success, or a\n\nBLE_HS_E[...]\n error code on failure.\n\n\nThe \nbleprph\n app registers its services as follows:\n\n\n \nrc\n \n=\n \nble_gatts_add_svcs\n(\ngatt_svr_svcs\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \nrc\n;\n }\n\n\n\n\n\nMore detailed information about the registration function can be found\nin the BLE User Guide: \nble_gatts_add
_svcs\n.\n\n\n\n\nRegistration callback function\n\n\nIt is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute:\n\n\nble_hs_cfg\n.\ngatts_register_cb\n \n=\n \ngatt_svr_register_cb\n;\n\n\n\n\n\nIn the above example \ngatt_svr_register_cb\n is the function that will be called. This line can be found in \nbleprph\n's \nmain.c\n file\n\n\nMore detailed information about the registration callback function can be found\nin the \nBLE User Guide\n (TBD).\n\n\n\n\nDescriptors and Included Services\n\n\nYour peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the \nBLE User Guide\n.",
"title": "Service Registration"
},
{
@@ -1392,14 +1392,19 @@
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#attribute-set",
- "text": "The NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code. bleprph uses a single attribute table located in the gatt_svr.c file,\nso let's take a look at that now. The attribute table is called gatt_svr_svcs ; here are the first several lines from this table: static const struct ble_gatt_svc_def gatt_svr_svcs [] = {\n {\n /*** Service: GAP. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid128 = BLE_UUID16 ( BLE_GAP_SVC_UUID16 ),\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Device
Name. */ \n . uuid128 = BLE_UUID16 ( BLE_GAP_CHR_UUID16_DEVICE_NAME ),\n . access_cb = gatt_svr_chr_access_gap ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Appearance. */ \n . uuid128 = BLE_UUID16 ( BLE_GAP_CHR_UUID16_APPEARANCE ),\n . access_cb = gatt_svr_chr_access_gap ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n // [...] As you can see, the table is an array of service definitions ( struct ble_gatt_svc_def ). This code excerpt contains a small part of the GAP service . The GAP service exposes generic information about a device,\nsuch as its name and appearance. Support for the GAP service is mandatory for\nall BLE peripherals. Let's now consider the contents of this table in more\ndetail. A service definition consists of the following fields: Field Meaning Notes
type Specifies whether this is a primary or secondary service. Secondary services are not very common. When in doubt, specify BLE_GATT_SVC_TYPE_PRIMARY for new services. uuid128 The 128-bit UUID of this service. If the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the BLE_UUID16() macro. characteristics The array of characteristics that belong to this service. A service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields: Field Meaning Notes uuid128 The 128-bit UUID of this characteristic. If the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the BLE_UUID16() macro. access_cb A callback function that gets executed whenever a peer device accesses this characteristic. For reads: this function generates the value that gets sent
back to the peer. For writes: this function receives the written value as an argument. flags Indicates which operations are permitted for this characteristic. The NimBLE stack responds negatively when a peer attempts an unsupported operation. The full list of flags can be found under ble_gatt_chr_flags in net/nimble/host/include/host/ble_gatt.h . The access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section: BLE Peripheral - Characteristic Access . The service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array. {\n /*** Alert Notification Service. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid128 = BLE_UUID16 ( GATT_SVR_SVC_ALERT_UUID ),\n . characteri
stics = ( struct ble_gatt_chr_def []) { {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_NEW_ALERT ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_NOTIFY ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_UNR_ALERT_STAT_UUID ),\n . access_cb = gatt_svr_chr_access_alert ,\n . flags = BLE_GATT_CHR_F_NOTIFY ,\n }, {\n . uuid128 = BLE_UUID16 ( GATT_SVR_CHR_ALERT_NOT_CTRL_PT ),\n . access_cb = gatt_svr_chr_access_alert ,\n .
flags = BLE_GATT_CHR_F_WRITE ,\n }, { 0 , /* No more characteristics in this service. */ } },\n },\n\n { 0 , /* No more services. */ },",
+ "text": "The NimBLE host uses a table-based design for GATT server configuration. The\nset of supported attributes are expressed as a series of tables that resides in\nyour C code. When possible, we recommend using a single monolithic table, as\nit results in code that is simpler and less error prone. Multiple tables\ncan be used if it is impractical for the entire attribute set to live in one\nplace in your code. bleprph uses a single attribute table located in the gatt_svr.c file,\nso let's take a look at that now. The attribute table is called gatt_svr_svcs ; here are the first several lines from this table: static const struct ble_gatt_svc_def gatt_svr_svcs [] = {\n {\n /*** Service: Security test. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid = gatt_svr_svc_sec_test_uuid . u ,\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Random number generator. */ \n
. uuid = gatt_svr_chr_sec_test_rand_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Static value. */ \n . uuid = gatt_svr_chr_sec_test_static_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n // [...] As you can see, the table is an array of service definitions ( struct ble_gatt_svc_def ). Let's now consider the contents of this table in more\ndetail. A service definition consists of the following fields: Field Meaning Notes type Specifies whether this is a primary or secondary service. Secondary services are not very common. When in doubt, specify BLE_GATT_SVC_TYPE_PRIMARY for new services. uuid The UUID of this characteristic. This field accepts a pointer to a variable of type ble_uuid_t . You could directly use the BLE_UUID16
_DECLARE() macro or to pass a pointer to a ble_uuid16_t variable you could type uuid_variable.u characteristics The array of characteristics that belong to this service. A service is little more than a container of characteristics; the\ncharacteristics themselves are where the real action happens. A characteristic\ndefinition consists of the following fields: Field Meaning Notes uuid The UUID of this characteristic. This field accepts a pointer to a variable of type ble_uuid_t . You could directly use the BLE_UUID16_DECLARE() macro or to pass a pointer to a ble_uuid16_t variable you could type uuid_variable.u access_cb A callback function that gets executed whenever a peer device accesses this characteristic. For reads: this function generates the value that gets sent back to the peer. For writes: this function receives the written value as an argument. flags Indicates which operations are permitted for this characteristic. The NimBLE sta
ck responds negatively when a peer attempts an unsupported operation. The full list of flags can be found under ble_gatt_chr_flags in net/nimble/host/include/host/ble_gatt.h . The access callback is what implements the characteristic's behavior. Access\ncallbacks are described in detail in the next section: BLE Peripheral - Characteristic Access . The service definition array and each characteristic definition array is\nterminated with an empty entry, represented with a 0. The below code listing\nshows the last service in the array, including terminating zeros for the\ncharacteristic array and service array. {\n /*** Service: Security test. */ \n . type = BLE_GATT_SVC_TYPE_PRIMARY ,\n . uuid = gatt_svr_svc_sec_test_uuid . u ,\n . characteristics = ( struct ble_gatt_chr_def []) { {\n /*** Characteristic: Random number generator. */ \n . uuid = gatt_svr_chr_sec_test_rand_uuid . u ,\n . acces
s_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, {\n /*** Characteristic: Static value. */ \n . uuid = gatt_svr_chr_sec_test_static_uuid . u ,\n . access_cb = gatt_svr_chr_access_sec_test ,\n . flags = BLE_GATT_CHR_F_READ ,\n }, { 0 , /* No more characteristics in this service. */ } },\n },\n\n { 0 , /* No more services. */ },",
"title": "Attribute Set"
},
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#registration-function",
- "text": "After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function: int ble_gatts_register_svcs ( const struct ble_gatt_svc_def *svcs ,\n ble_gatt_register_fn *cb , void *cb_arg ) The function parameters are documented below. Parameter Meaning Notes svcs The table of services to register. cb A callback that gets executed each time a service, characteristic, or descriptor is registered. Optional; pass NULL if you don't want to be notified. cb_arg An argument that gets passed to the callback function on each invocation. Optional; pass NULL if there is no callback or if you don't need a special argument. The ble_gatts_register_svcs() function returns 0 on success, or a BLE_HS_E[...] error code on failure. More detailed information about the registration callback function can be found\nin the BLE User Guide (TBD). The
bleprph app registers its services as follows: rc = ble_gatts_register_svcs ( gatt_svr_svcs , gatt_svr_register_cb , NULL );\n assert ( rc == 0 );",
+ "text": "After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function: int ble_gatts_add_svcs ( const struct ble_gatt_svc_def *svcs ) The function parameters are documented below. Parameter Meaning Notes svcs An array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0. The ble_gatts_register_svcs() function returns 0 on success, or a BLE_HS_E[...] error code on failure. The bleprph app registers its services as follows: rc = ble_gatts_add_svcs ( gatt_svr_svcs );\n if ( rc != 0 ) {\n return rc ;\n } More detailed information about the registration function can be found\nin the BLE User Guide: ble_gatts_add_svcs .",
"title": "Registration function"
},
+ {
+ "location": "/os/tutorials/bleprph/bleprph-svc-reg/#registration-callback-function",
+ "text": "It is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute: ble_hs_cfg . gatts_register_cb = gatt_svr_register_cb ; In the above example gatt_svr_register_cb is the function that will be called. This line can be found in bleprph 's main.c file More detailed information about the registration callback function can be found\nin the BLE User Guide (TBD).",
+ "title": "Registration callback function"
+ },
{
"location": "/os/tutorials/bleprph/bleprph-svc-reg/#descriptors-and-included-services",
"text": "Your peripheral can also expose descriptors and included services. These are\nless common, so they are not covered in this tutorial. For more information,\nsee the BLE User Guide .",
diff --git a/os/tutorials/bleprph/bleprph-svc-reg/index.html b/os/tutorials/bleprph/bleprph-svc-reg/index.html
index 0f772da123..670e50e799 100644
--- a/os/tutorials/bleprph/bleprph-svc-reg/index.html
+++ b/os/tutorials/bleprph/bleprph-svc-reg/index.html
@@ -598,30 +598,26 @@ <h4 id="attribute-set">Attribute Set</h4>
<p><br></p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #A90D91">static</span> <span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">gatt_svr_svcs</span>[] <span style="color: #000000">=</span> {
{
- <span style="color: #177500">/*** Service: GAP. */</span>
- .<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_SVC_UUID16</span>),
- .<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
- <span style="color: #177500">/*** Characteristic: Device Name. */</span>
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_CHR_UUID16_DEVICE_NAME</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_gap</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
- }, {
- <span style="color: #177500">/*** Characteristic: Appearance. */</span>
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">BLE_GAP_CHR_UUID16_APPEARANCE</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_gap</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
+ <span style="color: #177500">/*** Service: Security test. */</span>
+ .<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_svc_sec_test_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
+ <span style="color: #177500">/*** Characteristic: Random number generator. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_rand_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
+ .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
+ <span style="color: #177500">/*** Characteristic: Static value. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_static_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
+ .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
<span style="color: #177500">// [...]</span>
</pre></div>
<p><br></p>
<p>As you can see, the table is an array of service definitions (
-<code>struct ble_gatt_svc_def</code>). This code excerpt contains a small part of the
-<em>GAP service</em>. The GAP service exposes generic information about a device,
-such as its name and appearance. Support for the GAP service is mandatory for
-all BLE peripherals. Let's now consider the contents of this table in more
+<code>struct ble_gatt_svc_def</code>). Let's now consider the contents of this table in more
detail.</p>
<p>A service definition consists of the following fields:</p>
<table>
@@ -639,9 +635,9 @@ <h4 id="attribute-set">Attribute Set</h4>
<td>Secondary services are not very common. When in doubt, specify <em>BLE_GATT_SVC_TYPE_PRIMARY</em> for new services.</td>
</tr>
<tr>
-<td>uuid128</td>
-<td>The 128-bit UUID of this service.</td>
-<td>If the service has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the <code>BLE_UUID16()</code> macro.</td>
+<td>uuid</td>
+<td>The UUID of this characteristic.</td>
+<td>This field accepts a pointer to a variable of type <code>ble_uuid_t</code>. You could directly use the <code>BLE_UUID16_DECLARE()</code> macro or to pass a pointer to a <code>ble_uuid16_t</code> variable you could type <code>&uuid_variable.u</code></td>
</tr>
<tr>
<td>characteristics</td>
@@ -652,7 +648,7 @@ <h4 id="attribute-set">Attribute Set</h4>
</table>
<p><br></p>
<p>A service is little more than a container of characteristics; the
-characteristics themselves are where the real action happens. A characteristic
+characteristics themselves are where the real action happens. A characteristic
definition consists of the following fields:</p>
<table>
<thead>
@@ -664,9 +660,9 @@ <h4 id="attribute-set">Attribute Set</h4>
</thead>
<tbody>
<tr>
-<td>uuid128</td>
-<td>The 128-bit UUID of this characteristic.</td>
-<td>If the characteristic has a 16-bit UUID, you can convert it to its corresponding 128-bit UUID with the <code>BLE_UUID16()</code> macro.</td>
+<td>uuid</td>
+<td>The UUID of this characteristic.</td>
+<td>This field accepts a pointer to a variable of type <code>ble_uuid_t</code>. You could directly use the <code>BLE_UUID16_DECLARE()</code> macro or to pass a pointer to a <code>ble_uuid16_t</code> variable you could type <code>&uuid_variable.u</code></td>
</tr>
<tr>
<td>access_cb</td>
@@ -680,39 +676,29 @@ <h4 id="attribute-set">Attribute Set</h4>
</tr>
</tbody>
</table>
-<p>The access callback is what implements the characteristic's behavior. Access
+<p>The access callback is what implements the characteristic's behavior. Access
callbacks are described in detail in the next section:
<a href="../bleprph-chr-access/">BLE Peripheral - Characteristic Access</a>.</p>
<p>The service definition array and each characteristic definition array is
-terminated with an empty entry, represented with a 0. The below code listing
+terminated with an empty entry, represented with a 0. The below code listing
shows the last service in the array, including terminating zeros for the
characteristic array and service array.</p>
<p><br></p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> {
- <span style="color: #177500">/*** Alert Notification Service. */</span>
+ <span style="color: #177500">/*** Service: Security test. */</span>
.<span style="color: #000000">type</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_SVC_TYPE_PRIMARY</span>,
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_SVC_ALERT_UUID</span>),
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_svc_sec_test_uuid</span>.<span style="color: #000000">u</span>,
.<span style="color: #000000">characteristics</span> <span style="color: #000000">=</span> (<span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_chr_def</span>[]) { {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
+ <span style="color: #177500">/*** Characteristic: Random number generator. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_rand_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
.<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_NEW_ALERT</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_NOTIFY</span>,
- }, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_SUP_UNR_ALERT_CAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
+ <span style="color: #177500">/*** Characteristic: Static value. */</span>
+ .<span style="color: #000000">uuid</span> <span style="color: #000000">=</span> <span style="color: #000000">&gatt_svr_chr_sec_test_static_uuid</span>.<span style="color: #000000">u</span>,
+ .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_sec_test</span>,
.<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_READ</span>,
}, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_UNR_ALERT_STAT_UUID</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_NOTIFY</span>,
- }, {
- .<span style="color: #000000">uuid128</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_UUID16</span>(<span style="color: #000000">GATT_SVR_CHR_ALERT_NOT_CTRL_PT</span>),
- .<span style="color: #000000">access_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_chr_access_alert</span>,
- .<span style="color: #000000">flags</span> <span style="color: #000000">=</span> <span style="color: #000000">BLE_GATT_CHR_F_WRITE</span>,
- }, {
<span style="background-color: #ffffcc"> <span style="color: #1C01CE">0</span>, <span style="color: #177500">/* No more characteristics in this service. */</span>
</span> } },
},
@@ -727,8 +713,7 @@ <h4 id="attribute-set">Attribute Set</h4>
<h4 id="registration-function">Registration function</h4>
<p>After you have created your service table, your app needs to register it with the NimBLE stack. This is done by calling the following function:</p>
<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #A90D91">int</span>
-<span style="color: #000000">ble_gatts_register_svcs</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">*svcs</span>,
- <span style="color: #000000">ble_gatt_register_fn</span> <span style="color: #000000">*cb</span>, <span style="color: #A90D91">void</span> <span style="color: #000000">*cb_arg</span>)
+<span style="color: #000000">ble_gatts_add_svcs</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">struct</span> <span style="color: #000000">ble_gatt_svc_def</span> <span style="color: #000000">*svcs</span>)
</pre></div>
@@ -744,31 +729,33 @@ <h4 id="registration-function">Registration function</h4>
<tbody>
<tr>
<td>svcs</td>
-<td>The table of services to register.</td>
+<td>An array of service definitions to queue for registration. This array must be terminated with an entry whose 'type' equals 0.</td>
<td></td>
</tr>
-<tr>
-<td>cb</td>
-<td>A callback that gets executed each time a service, characteristic, or descriptor is registered.</td>
-<td>Optional; pass NULL if you don't want to be notified.</td>
-</tr>
-<tr>
-<td>cb_arg</td>
-<td>An argument that gets passed to the callback function on each invocation.</td>
-<td>Optional; pass NULL if there is no callback or if you don't need a special argument.</td>
-</tr>
</tbody>
</table>
<p>The <code>ble_gatts_register_svcs()</code> function returns 0 on success, or a
<em>BLE_HS_E[...]</em> error code on failure.</p>
-<p>More detailed information about the registration callback function can be found
-in the <a href="../../../../network/ble/ble_intro/">BLE User Guide</a> (TBD).</p>
<p>The <em>bleprph</em> app registers its services as follows:</p>
-<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">ble_gatts_register_svcs</span>(<span style="color: #000000">gatt_svr_svcs</span>, <span style="color: #000000">gatt_svr_register_cb</span>, <span style="color: #A90D91">NULL</span>);
- <span style="color: #000000">assert</span>(<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #1C01CE">0</span>);
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span> <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">ble_gatts_add_svcs</span>(<span style="color: #000000">gatt_svr_svcs</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">rc</span>;
+ }
+</pre></div>
+
+
+<p>More detailed information about the registration function can be found
+in the BLE User Guide: <a href="../../../../network/ble/ble_hs/ble_gatts/functions/ble_gatts_add_svcs/">ble_gatts_add_svcs</a>.</p>
+<p><br></p>
+<h4 id="registration-callback-function">Registration callback function</h4>
+<p>It is possible to set a callback function that gets executed each time a service, characteristic, or descriptor is registered. This is done by setting the following attribute:</p>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span></span><span style="color: #000000">ble_hs_cfg</span>.<span style="color: #000000">gatts_register_cb</span> <span style="color: #000000">=</span> <span style="color: #000000">gatt_svr_register_cb</span>;
</pre></div>
+<p>In the above example <code>gatt_svr_register_cb</code> is the function that will be called. This line can be found in <em>bleprph</em>'s <code>main.c</code> file</p>
+<p>More detailed information about the registration callback function can be found
+in the <a href="../../../../network/ble/ble_intro/">BLE User Guide</a> (TBD).</p>
<p><br></p>
<h4 id="descriptors-and-included-services">Descriptors and Included Services</h4>
<p>Your peripheral can also expose descriptors and included services. These are
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services