- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am sending data from android device to PSoc.By using
offdelayData[0] = wrReqParam->handleValPair.value.val[0];
offdelayData[1] = wrReqParam->handleValPair.value.val[1];
offdelayData[2] = wrReqParam->handleValPair.value.val[2];
offdelayData[3] = wrReqParam->handleValPair.value.val[3];
offdelayData[4] = wrReqParam->handleValPair.value.val[4];
offdelayData[5] = wrReqParam->handleValPair.value.val[5];
I get six bytes from device one by one.
In order to concatenate I converted each bytes to character by using
utoa(offdelayData[0], t0,10 );
utoa(offdelayData[1],t1,10 );
utoa(offdelayData[2],t2,10 );
utoa(offdelayData[3],t3,10);
utoa(offdelayData[4],t4,10);
utoa(offdelayData[5],t5,10 );
and then concatenated to "t0"
strcat(t0,t1);
strcat(t0,t2);
strcat(t0,t3);
strcat(t0,t4);
strcat(t0,t5);
then initialised to char *t=t0;
then converted to integer
OffDelay=strtoul(t, &ptr1, 10);
While executing it is advertising but not received in Android device.
Please Give suggestions.
By Joany.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Conversions like those are usually performed using shift left by 8 and ORing the result with the second byte resulting in a 16bit int.
When a 32bit result is expected use shift and ORs appropriately.
Your utoa() conversion requires as result an array of 4 characters: a byte can be as much as "255" and there is a trailing '\0" byte.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Conversions like those are usually performed using shift left by 8 and ORing the result with the second byte resulting in a 16bit int.
When a 32bit result is expected use shift and ORs appropriately.
Your utoa() conversion requires as result an array of 4 characters: a byte can be as much as "255" and there is a trailing '\0" byte.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob ,
Thanks for your suggestion.Now it works.
Regards
Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi bob,
I want to know how to read a variable value from Psoc in Android device.
Here I have a code
for( i=1;i<=time;i++)
{
Alert_LED_Write(1u);
ms_delay(OnDelay);
Alert_LED_Write(0u);
ms_delay(OffDelay);
}
in Psoc.
While executing,I want to read the value of 'i' in Android device.
Please Give suggestions.
Best Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Joanyfn
I had the same problem but the link below helped me alot
allaboutcircuits.com/projects/how-to-communicate-with-a-custom-ble-using-an-android-app/
cordially
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I'm not an Android man. 😉 Someone else must help here.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok Thanks Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using RTC for giving delay.I want to give ms delay but in RTC_sel only "2.0ms" period is there such that when I give "1" it gives "2.0ms" delay.
Is there any way to change "2.0ms" to "1.0ms" such that when I give "1" it gives "1.0ms" delay.
Give suggestions.
Best ,
Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
I am using
for(i=1;i<=5;i++)
{
if(!ledOnFlag && RTC_1_GetUnixTime() - startTime >= OffDelay)
{
Alert_LED_Write(LED_ON);
ledOnFlag = 1;
startTime = RTC_1_GetUnixTime();
}
if(ledOnFlag && RTC_1_GetUnixTime() - startTime >= (OnDelay))
{
Alert_LED_Write(LED_OFF);
ledOnFlag = 0;
startTime = RTC_1_GetUnixTime();
}
if(i>5)
{
break;
}
}
According to my code after 5 blink ,the LED must stop blinking but here the LED blinks continuously.
I want to stop blinking the LED at particular loop.
Give suggestions please
By Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The variable i cannot be greater than 5, only 1 to 5.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi bob,
ok. I reprogrammed as (modification shown in bold)
for(i=1;i<=5;i++)
{
if(!ledOnFlag && RTC_1_GetUnixTime() - startTime >= OffDelay)
{
Alert_LED_Write(LED_ON);
ledOnFlag = 1;
startTime = RTC_1_GetUnixTime();
}
if(ledOnFlag && RTC_1_GetUnixTime() - startTime >= (OnDelay))
{
Alert_LED_Write(LED_OFF);
ledOnFlag = 0;
startTime = RTC_1_GetUnixTime();
}
if(i>=5)
{
break;
}
}
yet LED blinks after 5 times.I have to stop the blinking of LED after 5 times.
Give suggestions.
Thanks and regards,
Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Joany, can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The alertlevel variable you act on is reset on a disconnect event only. So update() will blink the LED as long as alertlevel is reset. When you want to blink only once 5 times you should reset alertlevel when you acted on it.
For your help: Right click on "alertlevel" in your program and select "Show all active references" to see where it is used.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi bob,
Thank you for your suggestion.
How to reset alertlevel automatically such that the LED blinks for 5 times alone?
Give syntax or any suggestions to work it out.
Thanks and regards
Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reset the alertlevel after having blinked 5 times, just the line before you break the loop.
if(i>=5)
{
alertLevel = NOALERT;
break;
}
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi bob,
I heard about flash memory that it stores last written data .
I also want to know how to write and read data in flash such that onTime and offTime works properly(ie last written onTime and offTime value are taken automatically from flash memory).
I am using PSoc4
I found that function(uint32 CySysFlashWriteRow(uint32 rowNum, const uint8 rowData[]) is used to write data in flash.
Now I am using
ondelayData[0] = wrReqParam->handleValPair.value.val[0];
ondelayData[1] = wrReqParam->handleValPair.value.val[1];
ondelayData[2] = wrReqParam->handleValPair.value.val[2];
ondelayData[3] = wrReqParam->handleValPair.value.val[3];
ondelayData[4] = wrReqParam->handleValPair.value.val[4];
ondelayData[5] = wrReqParam->handleValPair.value.val[5];
ondelayData[6] = wrReqParam->handleValPair.value.val[6];
ondelayData[7] = wrReqParam->handleValPair.value.val[7];
to write data
and combined bytes by
onTime=(ondelayData[0]*10000000)+(ondelayData[1]*1000000)+(ondelayData[2] *100000) +(ondelayData[3] *10000) +(ondelayData[4] *1000) +(ondelayData[5] *100) +(ondelayData[6] *10)+ (ondelayData[7]*1);
Regards,
Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are some restrictions to consider:
Writing to flash changes internal clocking which get in conflict with a running BLE. Radio has to be shut down before.
There is a "Supervisory Flash" that allows for storing some data. An example is available in the 100 BLE Projects blog.
Flash may not be written too often. Depending on ambient temperature it may be as low as a few K times.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob ,
You have said to use
if(i>=5)
{
alertLevel = NOALERT;
break;
}
to reset automatically.
This I tried before and now also I tried .It just blink once and stop .Not after 5 times.
Please give suggestions.
Thanks and regards
Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, but I cannot deduct from your code what exactly you want to perform.
What has your blinking LED to do with the alert state which will change with every call to StackEventHandler()
Why are you using a slow blinking 2Hz ?
What you want with the blinking when the alert state is changing when not yet 5 blinks. (Set up a table)
Why don't you use an independent interrupt driven counter event to blink the LED
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Now just I am doing simple project with 5 blinks.
ok.I will try by using an independent interrupt driven counter event to blink the LED.
Thanks and regards
From Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you use a timer component it will be easier to perform. Take a TCPWM configured as timer with 500ms, so you'll get a blink frequency of 1Hz.
No delays, no waiting, no for/while loops within your interrupt handler!!!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Thank you for your suggestions.I will try it and contact you.
Regards Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
I referred your example related to SFlash.Should I want to write a separate program to write datas on SFlash?Should I create registers?
Can I assign any starting address of user SFlash row?
By Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No offending: But your experiences in programming are not yet too good.
Stick to following advices:
Care for correct indentation this will help you to keep track of program flow. Could be helpful to set indenting with tabs.
Avoid else ifs These are commonly mis-interpreted by us programmers.
Avoid blank lines except for single ones separating blocks of code
Use comments to indicate what you want to do Only this way you can compare with what you actually did
Under Creator->Help you can access the "System Reference Guide". There is a chapter how to declare and define interrupt handlers.
Use the isr_StartEx() mechanism and do not tamper in the created files.
Regarding your last post
Should I want to write a separate program to write datas on SFlash? When you are meaning writing a subroutine / function, that will be ok.
Should I create registers? You cannot create registers, they are already there.
Can I assign any starting address of user SFlash row? Not sure what you mean: The complete flash area is divided into rows of equal size. Writing to flash will write one row completely. There are constants defining the number of rows and the size of each one.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok .Thanks Bob .I will try.
By Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
Thanks. Using the isr_StartEx() mechanism.I set the flag. I made the firmware such a way that system is going to deep sleep only when the Blinking process has been stopped.Now its working fine.
I will contact you later.
By Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Makes me feel glad to have helped you!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In my project when LED is ON voltage is 0v and when LED is OFF voltage is 3.3v.
I want to know how to interchange the voltage of LED ON and LED OFF.
That is when LED is ON voltage must be 3.3v and when LED is OFF voltage must be 0v.
Do I need to modify in cydwr file??
Give suggestion.I have hereby attach the project.
By Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That depends on the board layout. I frequently use
//***********************************************************************************//
//**************** Definitions and Macros *******************************************//
//***********************************************************************************//
#define FALSE (0) // Define logical false and true values
#define TRUE (!FALSE) //
#define forever TRUE // I like that for infinite loops
#define ActiveHigh TRUE // LEDs are active high in this application
#define LEDON ActiveHigh // LED state definition
#define LEDOFF !LEDON // Now we can use LED_Write(LEDOFF)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob. I followed your ideas .Yet when LED is ON ,voltage is 0v and when LED is OFF ,voltage is 3.3v.
I want to make the LEDON voltage 3.3v and LEDOFF voltage 0v.
By Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then you will have to change the hardware.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok.Thanks Bob
By Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
I am having CY8C4247LQI-BL483 .
What type of hardware is required for implementing LEDON voltage as 3.3v and LEDOFF voltage as 0v?
Thanks and Regards,
From Joany
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Joany,
You have as an electronic designer two different methods to light an LED since the "D" stands for "Diode".
You may connect the cathode to ground and light the LED with a positive signal
or
you may connect the anode to Vcc and light the LED with a negative signal. This form is often taken because the signal drivers usually are able to sink more current than to source.
I cannot recommend to tamper the board, but you may use another LED together with a resistor connected to an output pin of your board to light that LED with a positive signal.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
It works.Thank you for your valuable suggestions.
By Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are always welcome!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob,
I want to work with three LEDS individually by using WDT interrupt in RTC.
But it seems to be working with one timer in RTC.
How to select three timers in RTC and control three LEDS individually?
I hereby attach the project and image of selecting one timer in RTC.
Regards ,
Joany.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When Timer ISR is set to "Automatic" you cannot get in between. Set it to "User generated" and call RTC_Update() yourself. You will need a "Global Signal Reference" set to WDT and an isr component. Furthermore you can maintain a software timer that cares for your LEDs in the interrupt handler.
Bob.