cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 6

BoBr_4596421
New Contributor II

Hello there,

I would be grateful for some help with diagnostics in getting BLE to operate correctly.

I have been following the tutorials from Aan Hawse and am up to Tutorial 3-2.

I am not getting any discovery on my phone. I have attached my code.

Status

1) CYBLE-416045-02 prototype board

2) PSoC Creator 4.2

3) PDL version 3.1.0

4) Windows 10 (latest status)

Code status

a) Build and Compile was error free

b) The RED LED on the prototype board started flashing immediately after programming had completed (correct)

c) The serial monitor reported 'Started Task', 'System Started' and 'BLE Task Started' (correct)

d) With the CySMART app on my Android phone, and successfully paired, I get 'Refreshing, please Wait', followed by 'Pull down to Refresh' - but all I see on the phone are blank screens and I should be seeing the customer service being advertised.

Any insights would be really helpful - thanks.

Regards

Bob

0 Likes
1 Solution
NazarP_56
Employee

Hi Bob,

I reviewed the attached project and found the place which can cause to unexpected behaviour. Not sure if it is your case.

Please do the following modifications:
1. main_cm4.c line#19, initialize bleSemaphore by NULL bleSemaphore leSemaphbleSemaphore ore

SemaphoreHandle_t bleSemaphore = NULL;

2. main_cm4.c, In main function, Create semaphore by using macros vSemaphoreCreateBinary(). It should be done before create bleTask:

int main(void)

{

    __enable_irq(); /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    UART_1_Start();

    setvbuf(stdin,NULL,_IONBF,0);

    setvbuf(stdout,NULL,_IONBF,0);

    printf("System Started\r\n");

   

    PWM_DIM_Start();

    PWM_BLINK_Start();

   

   vSemaphoreCreateBinary(bleSemaphore);

   

    xTaskCreate(bleTask,"bleTask",8*1024,0,2,0);

   

    vTaskStartScheduler();

   

    for(;;)

    {

        /* Place your application code here. */

    }

}


If this does not solve your problem, please inform what phone and Android version do you use?

Regards,
Nazar

View solution in original post

0 Likes
4 Replies
NazarP_56
Employee

Hi Bob,

I reviewed the attached project and found the place which can cause to unexpected behaviour. Not sure if it is your case.

Please do the following modifications:
1. main_cm4.c line#19, initialize bleSemaphore by NULL bleSemaphore leSemaphbleSemaphore ore

SemaphoreHandle_t bleSemaphore = NULL;

2. main_cm4.c, In main function, Create semaphore by using macros vSemaphoreCreateBinary(). It should be done before create bleTask:

int main(void)

{

    __enable_irq(); /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    UART_1_Start();

    setvbuf(stdin,NULL,_IONBF,0);

    setvbuf(stdout,NULL,_IONBF,0);

    printf("System Started\r\n");

   

    PWM_DIM_Start();

    PWM_BLINK_Start();

   

   vSemaphoreCreateBinary(bleSemaphore);

   

    xTaskCreate(bleTask,"bleTask",8*1024,0,2,0);

   

    vTaskStartScheduler();

   

    for(;;)

    {

        /* Place your application code here. */

    }

}


If this does not solve your problem, please inform what phone and Android version do you use?

Regards,
Nazar

View solution in original post

0 Likes
BoBr_4596421
New Contributor II

Hi Nazar,

(Sorry for delay in getting back to you).

Perfect catch Nazar - the 'vSempahoreCreateBinary' code was missing from Alan's tutorial and its addition to the code allowed the program to execute. It works with several phones and previously did not work on several phones, so I am happy that the error was not phone-related.

I have a relatively minor question on how this ends up - from the phone - and after clicking through the 'P6LED' option, the phone goes into 'discovering services' mode. After a short delay, it then shows two services available - a) 'GATT DB' and b) 'Unknown Service'.

I'm wondering why the 'Unknown Service' is not titled 'LED' as per the server option in the BLE module (see below).

PS The 'Unknown Service' also shows (below the icon on the phone) a long alphanumeric which corresponds exactly to the UUID shown in the screenshot - so why is the BLE service not picking up a name?

BLE Custom Service name.PNG

Regards

Bob

NazarP_56
Employee

Hi Bob,

Regarding to CySmart - it is expected behavior. CySmart can recognize many adopted Services (e.g BAS, HRS, LNS, etc).

Please refer to CySmart™ Android App User Guide.pdf for more details.

In above project we use custom service for LED control. So for CySmart this service is unknow and when you click on this service, CySmart will open GATT DB window, where you can execute common operations: write, read, etc .


FYI, Services or characteristics name, which you see in BLE Customizer are visible only in application, but Discovery procedure (on Central side) returns only Attribute handle and UUID (and not returns Name, like "LED" or "GREEN" ).

I opened internal ticket to fix semaphore issue in PSoC6-101-Video-Projects.

Regards,
Nazar

BoBr_4596421
New Contributor II

Hi Nazar,

Thanks for helpful reply. I now understand.

And thanks also for raising a ticket on the tutorial to assist others.

I'm not sure how many people will be copying code from the videos like I do. It's obviously a lot slower and more error-prone compared to downloading fro GitHub but it works for me from a learning standpoint.

Thanks again.

Regards

Bob

0 Likes
Top labels