![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 37
| 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();
}
here: Code: // send a message
if( status == 0 ) {
status = write(s, "STOP" , 6);
}
Code: bt_send(START); Code: // send a message
if( status == 0 ) {
status = write(s, "START" , 6);
}
Code: bt_send(STOP); Code: // send a message
if( status == 0 ) {
status = write(s, "STOP" , 6);
}
thanks in advance. |
| Ali.B is offline | |
| | #2 |
| Registered User Join Date: May 2009
Posts: 50
| ....C basic Code: #define START "START"
#define STOP "STOP"
int bt_send( const char *SIGNAL )
{
/* .... whatever */
// send a message
if( status == 0 ) {
status = write( s, SIGNAL, 6 );
}
/* .... the rest */
}
int
main( void )
{
bt_send( START );
}
|
| bvkim is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 37
| C Basic... true that.... :P i should know these stuff but thanks bvkim... problem solved |
| Ali.B is offline | |
![]() |
| Tags |
| argument, call, function |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compiling sample DarkGDK Program | Phyxashun | Game Programming | 6 | 01-27-2009 03:07 AM |
| Seg Fault in Compare Function | tytelizgal | C Programming | 1 | 10-25-2008 03:06 PM |
| A Function Calling a Function | dac | C++ Programming | 8 | 12-17-2006 04:10 PM |
| <Gulp> | kryptkat | Windows Programming | 7 | 01-14-2006 01:03 PM |
| Please Help - Problem with Compilers | toonlover | C++ Programming | 5 | 07-23-2005 10:03 AM |