hello,
i have some problems sending data via bluetooth.
the demo software is just working fine and i can receive the accl-data on the terminal screen.
now i want to modify the demo code that way that i just want to send some data, like a bunch of numbers or letters.
i know that there are a lot of different sending, writing and reading functions in the demo-code. my problem is to find the right place within the code to place my "code".
i would like to know where to modify the code for my special purposes and which files a have to modyfie.
thanks alot for your help
If you are using MindTree’s stack, you can start with this simple application, the UART bridge:
http://processors.wiki.ti.com/index.php/CC256x_MT_UART_BRIDGE
The stack uses FreeRTOS, which divides user code in tasks (ie. user_task.c).
Let me know if you have any questions,
ZH
------------------------------------------------------------------------------------------Please click the Verify Answer button on this post if it answers your question.
Please visit our CC256x Forum Guidelines and FAQs
Check out our CC256x Bluetooth Main Wiki page: http://processors.wiki.ti.com/index.php/CC256x
------------------------------------------------------------------------------------------
thaks for your reply...
i modified the code suggested in the wiki but i got some errors, exactly in the user_task.c file. i got the error "declaration is incompatible with previous "config_uart_send_timer" ". i just copy/paste this section out of the wiki thats why i dont understand this error.
any suggestions?
further i would like to know, where i can put my one "code" if the changes described in the wiki are finaly "running"?
thanks for your help
the "wiki-code modification" is now working, i just forgott something ;)
hello again ;)
as mentioned, the wiki-modification is now working...now i would like to know in wich file i have to put "my code", which should send data via blothooth from one target board (connected to the battery board) to the other board (connected to the PC) so i can see the incomming data on the terminal screen. as i already said, i know that there are different write, read and send functions but i cant figure out which is the "right" one for my purposes.
any help would be nice....
p.s.: i am totaly knew at this...
I'm not sure what it is you want to do but if you understand how the UART bridge code modification works, you should be able to create a task to send data. The user_task_routine in user_task.c is a task that runs periodically based on what is in the circular_user_buffer such as when SWITCH_S1 or SWITCH_S2 is pressed. You can use UPDATE_USER_BUFFER(YOUR_TASK_CODE) to add an additional task to be run inside user_task_routine where you can add your own switch statement:
case YOUR_TASK_CODE:
appl_spp_write(dev_index, halUsbReceiveBuffer, bytesToSend); //for example, to send data (line copied from UART bridge code)
break;
Regards,Zahid
thanks for your reply...
just to clerify my purposes:
i want to send some numbers, maybe through a counter, from the targetboard connected to the battery-kit to the other targetboard connected with usb to the pc...
its a kind of testsignal for further use...
i will try the way you mentioned and see if it works...
thanks again
hello zahid,
unfortunately it doesnt work...as i already said i am new to this stuff so please forgive me my innocence...
could you please explain in a more precise way how i should implement my "code"? i dont really get it but i am not able to phrase my problem...
i hope you can help me anyway and i really appreciate your help...
thanks alot
For example, if you want to send something from the battery board with a press of a button, you can try this: in appl_sdk.c in line 161:
case OP_PEER_DATASEND: { /* Dtasend stop and pause toggle button presses */ if (SDK_IS_SPP_CONNECTED(0)) { if (SDK_IS_SPP_TX_STARTED(0)) { /* Stop Sending Data */ SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_OFF);
} else { /* Start Sending Data */ SDK_SPP_CHANGE_TX_STATE(0, SDK_SPP_TX_ON);//appl_send_spp_data(0);
appl_spp_write(0, "hello", 5);
}
So this code snippet above(else statement) gets executed every other time SW2 is pressed(first time it stops sending data, second time it starts sending data).
If you look in user_task.c, how the above function is called when SW2 is pressed:
case SWITCH_S2: /* Switch SW2 is mapped to contol datasend stop and pause * functionality */ sdk_bluetooth_menu_handler(OP_PEER_DATASEND); break;
So if your UART bridge was working, this should write "hello" to the other device connected to the PC and display it on a serial terminal.
Hope this helps,
Zahid
thanks again for your advice...
one quick question though:
does the "code" youve mentioned need to be on both boards because i dont receive anything?
or is there maybe another change i have to do?
regards
The code to write data should be on the battery board. The receiver connected to the PC should automatically write whatever data it receives to the PC through UART.
For example in appl_spp.c (starting line 515):
case SPP_RECVD_DATA_IND: sdk_display("SPP_RECVD_DATA_IND -> Data received successfully\n"); sdk_display("\n----------------HEX DUMP------------------------\n"); for (index = 0; index < datalen; index++) { sdk_display("%02X ", l_data[index]); } sdk_display("\n------------------------------------------------\n");
// if (TRUE == sdk_usb_detected) {#ifdef PACKETISE_USB_DATA packet[INDEX_0] = SOH; /* SOH Character */ memcpy(&packet[INDEX_1], l_data, PAYLOAD_SIZE); packet[INDEX_5] = calculate_checksum(packet); packet[INDEX_6] = '\0'; halUsbSendString(packet);
if PACKETISE_USB_DATA is defined, it packetizes the 4 byte data it receives from other device and send it through the USB-UART to the PC. For your application, you can comment out where PACKETISE_USB_DATA is defined.
Another thing you could try is to start with the original code from the web and modify it to continuously send some data instead of accelerometer data: in sdk_pl.c (line 133)
//comment out accel. data
/* Pack the x and y co-ordinate values in to buffer */ buffer[0] = accl_x; buffer[1] = (accl_x >> 8); buffer[2] = accl_y; buffer[3] = (accl_y >> 8);
//replace with your data
buffer[0] = 'a';buffer[1] = 'b';buffer[2] = 'c';buffer[3] = 'd';
And you should see "abcd" instead of random accel data on your serial terminal.
Hope this helps,ZH
again thanks for your help!!!
as you mentioned i tried to send some letters with the original code...nevertheless i dont receive the lettters but instead some different accl-data, but i commented them out....so i dont understand why this is happening....when i just send the accl-data i receive some negativ nummbers....but when i write some letters in the buffer and comment out the accl-data i receive realy high numbers...is there any connection or do i miss something else? is there maybe a problem with the serial terminal? or do i have to change/modify other files too?
thanks alot for your help!!!
Are you using a general program like Putty or Hyperterminal which interprets the serial input as ASCII characters?
Regards,
im just using the hyperterminal from windows, so no special programm...
when the both devices are connected, im starting the demo to see the incoming data on the popup hyperterminal screen...
do i need another programm or is there any mistake im making?
thanks for your reply, regards
hello again...
i finally got my programm working and i receive data on the pc-screen.
but i still got some problems:
i got my counter function working (it just counts from 1 to 1000) it should count with a step size of "1" but sometimes two consecutive numbers have a step size of "2" or "3".
in the "CC256x MT UART BRIDGE wiki" it is said that there are two conditions to start sending data, first if the buffer is full and second if the timer expires.
in my case it should be the first condition...
my question is, how do i get the stored data to be immediately send, so that i really got i step size of "1" or at least a constant step size?
do i have to make all the the changes in the "CC256x MT UART BRIDGE wiki", or is there only one certain point which i have to change?
thanks again for your help, i appreciate it