hello people...
i'm having a problem with my program, its a bluetooth program that sends a message to another party using the given MAC address,
Code:
//rfcomm Sender
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
int bt_send()
{
struct sockaddr_rc addr = { 0 };
int s, status;
char dest[18] = "00:03:7A:AA:92:DE"; //Another Party MAC Address
// allocate a socket
s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
// set the connection parameters (who to connect to)
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = (uint8_t) 1;
str2ba( dest, &addr.rc_bdaddr );
// connect to server
status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
// send a message
if( status == 0 ) {
status = write(s, "STOP" , 6);
}
if( status < 0 ) perror("Error ");
close(s);
return 0;
}
int main()
{
bt_send();
}
i need to call this function( bt_send() ) with an argument, that sits where "STOP" is now located;
here:
Code:
// send a message
if( status == 0 ) {
status = write(s, "STOP" , 6);
}
how can i call this function with an argument, something like this:
this would do this:
Code:
// send a message
if( status == 0 ) {
status = write(s, "START" , 6);
}
or this:
that does this:
Code:
// send a message
if( status == 0 ) {
status = write(s, "STOP" , 6);
}
how can I do this?
thanks in advance.