Register and run KW36 Callback function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Register and run KW36 Callback function

ソリューションへジャンプ
996件の閲覧回数
SeokJin
Contributor II

Hello,

I am currently creating two-way Bluetooth communication utilizing the "KW36 Board" (Client device & Server device) and "KW36 SDK" (Low Power Temperature Sensor and Collector).

I have a question because I am having trouble registering and running the callback function during this process.

 

SeokJin_0-1709606087376.png

The picture shows "BleApp_Config(void)" in BLE temperature collector.c

As you can see "(void)App_RegisterGattClientProcedureCallback(BleApp_GattClientCallback);" "(void)App_RegisterGattClientNotificationCallback(BleApp_GattNotificationCallback);" It can be confirmed that callback registration functions such as "BleServDisc_RegisterCallback(BleApp_ServiceDiscoveryCallback);" are used, and it has also been confirmed that the callback functions "BleApp_GattClientCallback", "BleApp_GattNotificationCallback", and "BleApp_ServiceDiscoveryCallback", which are entered as internal arguments, are used inside the BLE temperature collector.c code.

 

Based on this process, I went through the process of registering a callback function to use the callback function of "Server" (temp sensor device).

SeokJin_1-1709606700403.png

You can look at line 439 [(void)App_RegisterGattServerCallback(BleApp_GattServerCallback);]. Here, (void)App_RegisterGattServerCallback(); (callback registration function) operates normally (the callback function is registered), but it does not work even if you add the "BleApp_GattServerCallback()" function in the actual BLE temp collector.c.

 

This is a photo of the BleApp_GattServerCallback() function actually added to the BLE temp collector.c code.

SeokJin_2-1709607162471.png

However, the operation of the function cannot be confirmed in Putty... When I see that the output text written within the function is not output, I think the function is not working.

 

In this case, what is the problem? How do I run the "BleApp_GattServerCallback()" callback function?

 

I'm waiting for your reply. thank you.

 

Regards,

SeokJin.

ラベル(1)
0 件の賞賛
返信
1 解決策
874件の閲覧回数
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

Perhaps you could refer to the Core Specification 5.0 | Bluetooth® Technology Website  Vol 3, Part F Attribute Protocol; and Part G Generic Attribute Profile for more information, in addition to the BLE Application Developer's Guide Chapter 5 GATT, Chapter 6 GATT database application interface, and Chapter 7 Creating GATT database.

For more information on GATT interface, Client and Server APIs, and GATT Database Interface, please refer to the BLE Host Stack API Reference Manual Chapter 5 - Chapter 7.

I apologize for insisting, please consider using the Wireless UART demo application as a reference for this implementation since this application implements both the GATT client and server.

Regards,
Eduardo.

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
975件の閲覧回数
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @SeokJin

Please, take a look at the BLE Application Developer Guide; Section 5.2 Server APIs, 5.2.1 Server Callback for more information on installation of the Server Callback.

Also, I will recommend you referring to Wireless UART demo application from the SDK. This application implements both the GATT client and server for the custom Wireless UART profile and services and perhaps you could use it as a reference.

Regards,
Eduardo.

0 件の賞賛
返信
953件の閲覧回数
SeokJin
Contributor II

Hello, @EduardoZamora  

Thanks for your answer. I checked the answers and referred to the developer guide and Wireless UART demo application examples.

Since I am currently using the Low Power Temperature Sensor and Collector demo application, I am replying using Low Power Temperature Sensor and Collector as an example.

Among them, based on BLE temperature sensor.c, as I asked before, you can see that a server callback is installed in BLEApp_Config(void); and utilized within the code.

You can also check that the installed server callback "BleApp_GattServerCallback(deviceId_t deviceId, gattServerEvent_t* pServerEvent)" has [deviceId] and [pServerEvent] as arguments.

SeokJin_0-1709861905090.png

 

SeokJin_1-1709861941573.png

 

Are these arguments automatically entered during Bluetooth connection (pairing) or Bluetooth communication between the temp sensor device and the temp collector device?

In relation to this, if the arguments of the installed server callback function are not entered correctly, may the server callback not run?

 

I'm waiting for your reply. thank you.

Regards,

SeokJin.

タグ(1)
0 件の賞賛
返信
905件の閲覧回数
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

The GATT Server Callback is triggered whenever the Client attempts to write the value of an attribute after the corresponding attribute handle has been registered.

More information on this can be found in the BLE Application Developer Guide, Section 5.2.3 Attribute write notifications.

Regards,
Eduardo.

0 件の賞賛
返信
880件の閲覧回数
SeokJin
Contributor II

Hello, @EduardoZamora 

Thank you for the reply.

I am replying because I have some questions while studying further based on BLE Developer Guide docs provided.

 

First, the answer was that in order for the server callback function to be triggered, an attribute handle must be registered and the client must attempt to write the attribute value.

Here, what docs should I refer to to learn how a specific device (Client? or Server?) registers an attribute handle?

I am currently learning based on the "Low Power Temperature Sensor and Collector" demo application, and I would be very grateful if you could tell me which part of the demo I should look at.

 

Second question. I'm curious what exactly is the trigger condition for the GattClientCallback function. I checked the guidebook docs, but I still don't quite understand it, so I hope you can answer to make it a little easier to understand.

SeokJin_0-1710343401910.png

This is the Client callback function I am curious about. I am curious about the trigger conditions for each callback function: "GattClientProcedureCallback" and "BleApp_GattClientCallback", "GattClientNotificationCallback" and "BleApp_GattNotificationCallback", "BleServDisc_RegisterCallback" and "BleApp_ServiceDiscoveryCallback", and additionally "GattServer_RegisterHandlesForWriteNotifications".

I'm so sorry for taking up your time. It's because I don't understand well. This information is very necessary for the success of my project, so please give me a kind and detailed answer. Please be my life saver.

 

As a final question, regarding GattClientProcedureCallback, if you look at the BLE Developer Guide docs, it is written as if all procedures started by the Client are asynchronous, and the GattClientProcedureCallback is triggered when the procedure completes.

SeokJin_3-1710344200180.png

Based on this information, I implemented GattClientProcedureCallback as code on the Server (Sensor device) to implement two-way BLE communication using the Low Power Temperature Sensor and Collector example, but it did not work. I think this is related to my second question. Is it not working because the trigger conditions are not met?

 

As I said before, there are a lot of questions and the content may be easy for others, but there are many parts that are difficult to understand based on my current knowledge. Please understand and we are waiting for your kind and detailed response.

Thank you so much in advance.

Best Regard,

SeokJin

0 件の賞賛
返信
875件の閲覧回数
EduardoZamora
NXP TechSupport
NXP TechSupport

Hi,

Perhaps you could refer to the Core Specification 5.0 | Bluetooth® Technology Website  Vol 3, Part F Attribute Protocol; and Part G Generic Attribute Profile for more information, in addition to the BLE Application Developer's Guide Chapter 5 GATT, Chapter 6 GATT database application interface, and Chapter 7 Creating GATT database.

For more information on GATT interface, Client and Server APIs, and GATT Database Interface, please refer to the BLE Host Stack API Reference Manual Chapter 5 - Chapter 7.

I apologize for insisting, please consider using the Wireless UART demo application as a reference for this implementation since this application implements both the GATT client and server.

Regards,
Eduardo.

0 件の賞賛
返信