I have 2 DA14580AK EVB and loaded DSPS device & host application into 2 different EVB. I set the break point in gapm_adv_report_ind_handler of host, and display the values of param->report.adv_addr.addr & param->report.data in watch view. The Dialog host can display the Dialog device name and BD address correctly. If the Dialog host receives another brand BLE's advertisement message, only BD address can be received correctly but received device name is garbage. However, DSPS android app can display those device names correctly, please kindly advise.
int gapm_adv_report_ind_handler(ke_msg_id_t const msgid,
const struct gapm_adv_report_ind *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
memset(gBdAddress, 0, sizeof(struct bd_addr));
memcpy(gBLEname, param->report.data, param->report.data_len);
memcpy(gBdAddress, param->report.adv_addr.addr, sizeof(struct bd_addr));
if(!memcmp(¶m->report.data[3], APP_DFLT_ADV_DATA, APP_DFLT_ADV_DATA_LEN))
{
//Save found bd_addr to global variable
memcpy(&connect_bdaddr, param->report.adv_addr.addr, sizeof(struct bd_addr));
app_cancel_scanning();
}
return (KE_MSG_CONSUMED);
}
Hi jackiechau,
What do you mean when you say "garbage", when you get the advertising indication the hexadecimal value are the one that should be ? Perhaps you also see data from previous indications since you dont memset the array that you are storing the advertising string.
Thanks MT_dialog
Hi MT_dialog,
"garbage" means correct device name can't be got although relevant BdAddress can be received. However, DSPS android app can display those device names correctly. Thanks.
Hi jackiechau,
What about the hex values that you are getting when you get an advertising indication, can you please check them and not the ascii characters ? Can you please check the param->report.data parameter and not the array that you are copying the data ? Or perhaps due to optization you cant check the actual data, can you please try to print the data instead of checking them in the debugger ? althougn i was able to see valid data when an advertising indication come on my setup.
Thanks MT_dialog
Hi MT_dialog,
Please find the attachment. It's one the of device names showing incorrect HEX values. I tried to print param->report.data parameter via console and the results were the same. Dialog device name could be shown, I don't think that it's related to optimization issue, please kindly advise.
Hi jackiechau,
Seems a bit weird, as far as i can see from your screenshot the AD flags are properly shown in the debugger 0x02, 0x01 and 0x06, the 1A is the length of your data as reported by the advertising string and the FF is the manufacturer specific data. Its a bit weird if the 580 filters out the next bytes. Are you sure about the values that you are placing in the advertising string ? Can you please check with an application that only parses the advertising string like BlueLoupe. Perhaps what you are seeing in the app you are using is device names that have been cached by your phone and not the actual advertising string.
Thanks MT_dialog
Hi MT_dialog,
Actually, the advertising strings are received via the air, they aren't transmitted by me. I just wondered why DSPS apk or my BLE monitor(PC app with USB BLE module) could receive those advertisements but it's not the case in my Dialog host.
Also, I have another question. In host DSPS project, sleep mode is disable. I put a printf_string("T") in the while loop of main_func. When the program was run by debugger, several hundred "T" was printed, then nothing. I stopped the debugger and ran again, one more "T" was printed. What's going on? I expected continuous "T" was printed, please kindly advise.
Hi jackiechau,
As i have mentioned in the screenshot you ve attached i can see the flags of an advertising string, and the host (at least on my side can receive the advertsing string properly, when i place a name in the advertising string i can check the name in the extra array variables), now regarding that your other devices are able to check names perphaps is because those devices can cache the names of connected devices or something like that or the devices can read names from the scan response data string. In order to be sure you can advertise with a peripheral and catch the advertising of your peripheral with your central and check the name that you ve placed in your device's advertising string. Also another thing that
As far as the printing the "T" try to use the function that directly uses the UART for example uart_write("T", 1, NULL);
Thanks MT_dialog
Hi MT_dialog,
我发现当app_cancel_scanning()或app_disconnect() was called, "T" wasn't printed. After app_scanning() or app_connect() was called, continuous "T" was printed. It seems the program counter stops when app_cancel_scanning() or app_disconnect() was run, until interrupt is received. It's proved by adding systick timer. Please kindly advise. Also, is it possible to assign your HK staff to help me, thanks?
Also, many developers requested help on I2C slave issue, will your side plan to take a look on this?
Hi Jackiechau,
A mail is sent to the registered email address.
Thanks MT_dialog
Hi MT_dialog,
Because sometimes peripheral device disconnects and are unable to connect central forever, I tried to issue app_reset_app() after disconnection by pressing a button. At this moment, although central could receive advertisement and connect to peripheral device, peripheral device couldn't receive central's transmitted data. After calling app_reset_app(), is there any state change or should I need to initial some codes in order that central can connect it again?
Also, it seems the BLE timer stopped after issuing app_reset_app(), I observed that the handler of app_timer_set wasn't triggered. Thanks.
Hi jackiechau,
你不需要为了发送一个重置命令reconnect to a device, most probably something is wrong with the way you are issuing a connection request to the peripheral. Can you please paste the code that you are using in order to connect from the central ? Also on which SDK you are developing, you are using the DSPS on the SDK5 or on SDK3 as an example? What do you mean that The peripheral couldn't receive the centrals trasmited data (notifications/indications) ? After a GAPM_RESET your device should be set from the app_easy_gap_dev_configure() (in SDK5) function which will set the role, operation, etc of your device.
Thanks MT_dialog
I'm using DSPS on SDK5.
At the central side, I input character via UART to scan, cancel scan, connect and disconnect peripheral device manually. I just used all the api your side provided.
static void uart_rx_callback(uint8_t res, uint32_t read_size)
{
struct bd_addr testDeviceAddr;
switch(rx_read_pointer[0]){
case 's':
app_scanning();
break;
case 'x':
app_cancel_scanning();
break;
case 'c':
if(ke_state_get(TASK_APP)==APP_CONNECTABLE){
printf_string("CONNECT\r\n");
app_connect();
}
break;
case 'd':
if(ke_state_get(TASK_APP)==APP_CONNECTED){
app_disconnect();
printf_string("DISCONNECT\r\n");
}
break;
case 'r':
printf_string("RESET stack\r\n");
app_reset_app();
break;
case 't':
printf_string("set APP_CONNECTABLE\r\n");
ke_state_set(TASK_APP, APP_CONNECTABLE);
break;
default:
break;
}
#endif
//reinitiate callback
uart_sps_read(rx_read_pointer, RX_CALLBACK_SIZE, &rx_state_ptr, &uart_rx_callback);
}
int gapc_disconnect_ind_handler(ke_msg_id_t const msgid,
struct gapc_disconnect_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
app_disconnect();
ke_state_set(TASK_APP, APP_CONNECTABLE);
printf_string("BLE connection lost\r\n");
return (KE_MSG_CONSUMED);
}
At the peripheral side, debug message would be printed in gapc_connection_req_ind_handler and and gapc_disconnect_ind_handler such that I could know whether the connection of peripheral device was connected or not.
In the last post, what I would like to say was sometimes the peripheral device may disconnect because of remote disconnection. When central trys to connect the periheral device again, it can't connect it again. Then I tried to issue app_reset_app in periheral device. At this moment, although central could receive advertisemnet and connect to peripheral device, when central tried to send data by app_uart_push in connected mode, peripher device couldn't receive anything.
Also, at peripheral side, I have added a timer by calling app_timer_set() to print debug message per 1 second. However, when app_reset_app was issued, I observed that the debug message was stopped to be printed.
Hi Jackiechau,
When you are connecting to the device (when using the app_connect() function) how do you allocate the gapm_start_connection_cmd message you are using the KE_MSG_ALLOC_DYN() or the KE_MSG_ALLOC() macro. For a proper connection theKE_MSG_ALLOC_DYN() should be used. By using this a GAPM_RESET command isn't required and the peripheral should be able to re-connect.
Thanks MT_dialog
Hi MT_dialog,
I'm using KE_MSG_ALLOC() as provided by the original source codes of SDK5. Why KE_MSG_ALLOC() isn't the best solution?
If I use KE_MSG_ALLOC_DYN() marco, how to define the parameter "length"?
Will the central side disconnect because of timeout?
Have you tried to test the connection of DSPS central and peripheral overnight?
Actually, whatever scanning, stop scanning, connect or disconnect, central does it manually by external event. Thanks.
Hi jackiechau,
In the DSPS host in the SDK5 the app_connect() - (is an SDK3 function) function is not used, instead the api function app_easy_gap_start_connection_to_set() function is used which uses the api function app_easy_gap_start_connection_to_msg_create() which in turns it calls the app_connect_start_msg_create(), the later function is the one that allocates the gapm_start_connection_cmd message by using the KE_MSG_ALLOC_DYN. The parameter length should be (sizeof(struct gap_bdaddr)). Regarding why you should use the KE_MSG_ALLOC_DYN, every message/struct that within the included parameters has a parameter member which is an empty array has to be allocated with the KE_MSG_ALLOC_DYN. In the SDK3 the KE_MSG_ALLOC is used and thats why we reset the stack afterwards, but this isn't the proper way to start or restart a connection. Yes the there is going to be a disconnection because of a timeout. I am not aware if the QA has performed an overnight test on the DSPS so i cant tell you for sure, but i suppose that those kind of tests are standard so i suppose that they have.
Thanks MT_dialog
I checked SDK3 should be used because DSPS project is only available for SDK3.
Hi jackiechau,
The DSPS is implemented in SDK 5 as well, please check the Dialog Serial Port Service in the reference designs. The most recent version is based on 5.0.3 SDK version.
Thanks MT_dialog