mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 17:24:32 +08:00
Preliminary support for indicators
This commit is contained in:
parent
86340d34bb
commit
2bda864bfb
@ -215,16 +215,67 @@ static int supported_features(struct audio_device *device, const char *buf)
|
||||
return headset_send(hs, "\r\nOK\r\n");
|
||||
}
|
||||
|
||||
static char *indicator_ranges(struct indicator *indicators)
|
||||
{
|
||||
int i;
|
||||
GString *gstr;
|
||||
|
||||
gstr = g_string_new("\r\n+CIND:");
|
||||
|
||||
for (i = 0; indicators[i].desc != NULL; i++) {
|
||||
if (i == 0)
|
||||
g_string_append_printf(gstr, "(\"%s\",(%s))",
|
||||
indicators[i].desc,
|
||||
indicators[i].range);
|
||||
else
|
||||
g_string_append_printf(gstr, ",(\"%s\",(%s))",
|
||||
indicators[i].desc,
|
||||
indicators[i].range);
|
||||
}
|
||||
|
||||
g_string_append(gstr, "\r\n");
|
||||
|
||||
return g_string_free(gstr, FALSE);
|
||||
}
|
||||
|
||||
static char *indicator_values(struct indicator *indicators)
|
||||
{
|
||||
int i;
|
||||
GString *gstr;
|
||||
|
||||
gstr = g_string_new("\r\n+CIND:");
|
||||
|
||||
for (i = 0; indicators[i].desc != NULL; i++) {
|
||||
if (i == 0)
|
||||
g_string_append_printf(gstr, "%d", indicators[i].val);
|
||||
else
|
||||
g_string_append_printf(gstr, ",%d", indicators[i].val);
|
||||
}
|
||||
|
||||
g_string_append(gstr, "\r\n");
|
||||
|
||||
return g_string_free(gstr, FALSE);
|
||||
}
|
||||
|
||||
static int report_indicators(struct audio_device *device, const char *buf)
|
||||
{
|
||||
struct headset *hs = device->headset;
|
||||
int err;
|
||||
char *str;
|
||||
struct indicator *indicators;
|
||||
|
||||
indicators = telephony_indicators_req();
|
||||
if (!indicators)
|
||||
return headset_send(hs, "\r\nERROR\r\n");
|
||||
|
||||
if (buf[7] == '=')
|
||||
err = headset_send(hs, "\r\n+CIND:(\"service\",(0,1)),"
|
||||
"(\"call\",(0,1)),(\"callsetup\",(0-3))\r\n");
|
||||
str = indicator_ranges(indicators);
|
||||
else
|
||||
err = headset_send(hs, "\r\n+CIND:1,0,0\r\n");
|
||||
str = indicator_values(indicators);
|
||||
|
||||
err = headset_send(hs, str);
|
||||
|
||||
g_free(str);
|
||||
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
@ -26,8 +26,26 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "telephony.h"
|
||||
|
||||
static struct indicator indicators[] =
|
||||
{
|
||||
{ "battchg", "0-5", 5 },
|
||||
{ "signal", "0-5", 5 },
|
||||
{ "service", "0,1", 1 },
|
||||
{ "sounder", "0,1", 0 },
|
||||
{ "message", "0,1", 0 },
|
||||
{ "call", "0,1", 0 },
|
||||
{ "callsetup", "0-3", 0 },
|
||||
{ "vox", "0,1", 0 },
|
||||
{ "roam", "0,1", 0 },
|
||||
{ "smsfull", "0,1", 0 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int telephony_init(void)
|
||||
{
|
||||
return 0;
|
||||
@ -45,3 +63,8 @@ int telephony_features_req(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct indicator *telephony_indicators_req(void)
|
||||
{
|
||||
return indicators;
|
||||
}
|
||||
|
@ -24,6 +24,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct indicator {
|
||||
const char *desc;
|
||||
const char *range;
|
||||
int val;
|
||||
};
|
||||
|
||||
int telephony_init(void);
|
||||
|
||||
void telephony_exit(void);
|
||||
@ -31,3 +37,5 @@ void telephony_exit(void);
|
||||
int telephony_features_req(void);
|
||||
|
||||
void telephony_features_rsp(uint32_t features);
|
||||
|
||||
struct indicator *telephony_indicators_req(void);
|
||||
|
Loading…
Reference in New Issue
Block a user