*
*/
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
if (count == 0) {
rem_bd_addr_array[0] = *p_address;
+ printf("There is first device:");
+ printba(p_address);
count++;
} else {
for (i = 0; i < count; i++) {
printf("There is no remote device suitable for connect\n");
stop=1;
}
+ /*
+ tiny_bt_finish();
+ stop = 1;
+ printf("Application finished\n");
+ */
}
void callback_app_connection_complete(__u16 *p_handle)
{
- char ar[6] = {"hallo "};
-
+ char ar[11] = {"hallo karel"};
+ char w2[15] = {"second messagee"};
+
connection_state state = CONNECT;
p_connection->con_state = state;
printf("Connection complete handle:%d\n", *p_handle);
- if (tiny_bt_send_data(ar, 6, p_handle) < 0) {
+ if (tiny_bt_send_data(ar, 11, p_handle, ACL_START, ACL_PPP) < 0) {
printf("unable to send data\n");
}
+ if (tiny_bt_send_data(w2, 15, p_handle, ACL_CONT, ACL_PPP) < 0) {
+ printf("unable to send data\n");
+ }
+ sleep(1);
tiny_bt_disconnect(p_handle, callback_app_disconnect);
}
void callback_app_disconnect(__u16 *p_handle, __u8 *p_reason)
{
printf("disconnection handle %d was completed\n", *p_handle);
+ tiny_bt_finish();
stop = 1;
}
-int main(void)
+int main(int argc, char* argv[])
{
- int ii = 30000;
+ //int ii = 30000;
- if (tiny_bt_init(0) < 0) {
+ if (tiny_bt_init(atoi(argv[1])) < 0) {
perror("device impossible to ititialize\n");
- return -1;
+ tiny_bt_finish();
+ exit(1);
}
printf("begin of main\n");
if (tiny_bt_read_bd_addr(&p_connection->master.bdaddr, callback_app_read_bd_addr) < 0) {
perror("tiny_bt_read_bd_addr error\n");
- return -1;
+ tiny_bt_finish();
+ exit(1);
}
while (1) {
if (stop)
- return -1;
- //ii--;
+ break;
if (tiny_bt_process() < 0) {
perror("process error");
- return -1;
+ tiny_bt_finish();
+ stop = 1;
}
}
+ printf("main finished\n");
return 0;
}