6 #include "com_client.h"
8 static com_config_t config;
9 static com_socket_t clt;
10 static com_connection_t connection;
14 C_RESULT init_com_client(void)
16 config.connection = COM_BLUETOOTH;
17 config.localAdapterName = DEVICENAME;
18 config.localIpAddress = CLIENTHOST;
19 config.localIpSubmask = SUBMASK;
21 if(FAILED(com_init(&config)))
27 C_RESULT run_com_client(COM_PROTOCOL protocol)
29 com_strToAddress(BTADDR_SERVER,&connection.address);
31 com_passKey(PIN_CODE);
32 if(FAILED(com_connect(&connection,1)))
35 clt.socket = COM_CLIENT;
36 clt.protocol = protocol;
38 if(protocol == COM_RFCOMM)
42 else if(protocol == COM_BNEP)
44 clt.port = BTADDR_PORT;
45 clt.serverHost = SERVERHOST;
50 if(FAILED(com_open(&clt,&read,&write)))
56 C_RESULT shutdown_com_client(void)
66 C_RESULT read_client(int8_t* buffer, int32_t* size)
68 return read(&clt,buffer,size);
71 C_RESULT write_client(const int8_t* buffer, int32_t* size)
73 return write(&clt,buffer,size);