extracted send rfcomm

This commit is contained in:
mila@ringwald.ch 2015-02-13 13:42:54 +00:00
parent fb4daa262f
commit baa06d2b73

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// minimal setup for SDP client over USB or UART
// Minimal setup for HSP Audio Gateway
//
// *****************************************************************************
@ -65,34 +65,33 @@ static uint8_t channel_nr = 0;
static uint16_t mtu;
static uint16_t rfcomm_cid = 0;
static char data[50];
static int send_err = 0;
static uint8_t connection_state = 0;
// remote audio volume control
static void hsp_set_microphone_gain(){}; // +VGM=13 [0..15]
static void hsp_set_speaker_gain(){}; // +VGS=5 [0..15]
static int send_str_over_rfcomm(uint16_t cid, char * command){
printf("Send %s.\n", command);
int err = rfcomm_send_internal(cid, (uint8_t*) command, strlen(command));
if (err){
printf("rfcomm_send_internal -> error 0X%02x", err);
}
}
static void send_packet(){
send_err = 0;
switch (connection_state){
case 1:
strcpy(data, "\r\nRING\r\n");
printf("Send RING.\n");
send_err = rfcomm_send_internal(rfcomm_cid, (uint8_t*) data, strlen(data));
send_str_over_rfcomm(rfcomm_cid, "\r\nRING\r\n");
connection_state++;
break;
case 3:
strcpy(data, "\r\nOK\r\n");
printf("Send OK.\n");
send_err = rfcomm_send_internal(rfcomm_cid, (uint8_t*) data, strlen(data));
send_str_over_rfcomm(rfcomm_cid, "\r\nOK\r\n");
connection_state++;
break;
default:
break;
}
if (send_err){
printf("rfcomm_send_internal -> error 0X%02x", send_err);
return;
}
}