Commit graph

139 commits

Author SHA1 Message Date
Barnabás Pőcze
436787d6ba treewide: try to use const char * for string literals 2023-09-16 17:47:35 +02:00
Barnabás Pőcze
4083502e03 spa: bluez: use some more spa_auto* 2023-07-30 13:45:49 +02:00
Barnabás Pőcze
ca85872e83 spa: bluez: use spa_auto for DBusError 2023-07-30 13:45:49 +02:00
Barnabás Pőcze
b52d590936 spa: bluez: add send_with_reply() dbus helper
This function sends a DBusMessage on a DBusConnection
and sets the reply callback of the resulting DBusPendingCall,
as well as properly cancelling the pending call if anything fails.
2023-07-30 13:45:49 +02:00
Barnabás Pőcze
6e581deb91 spa: bluez: use spa_autoptr for DBusMessage 2023-07-30 13:45:49 +02:00
Barnabás Pőcze
708e5443ae spa: bluez: add steal_reply_and_unref() helper
This function retrieves the reply from a DBusPendingCall and unrefs the call.
2023-07-15 01:04:23 +02:00
Barnabás Pőcze
667703e27d spa: bluez: backend-native: remove unnecessary array of DBusMessageIter 2023-07-14 22:35:35 +02:00
Barnabás Pőcze
66014e5828 spa: bluez: backend-native: fix DTMF string leak 2023-07-14 18:20:07 +02:00
Barnabás Pőcze
8c17a6626d treewide: mark some functions static
These were found by enabling the "missing-declarations" warning.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
4a555ed6ff spa: bluez: backend-native: fix a memory leak
In `_transport_create()`, if `spa_bt_transport_create()` failed
then `pathfd` would be leaked.
2023-06-29 23:57:48 +02:00
Barnabás Pőcze
54b0886c78 spa: bluez: backend-native: use correct pointer
The yolo pointer strikes again. Pass the correc pointer to `mm_unregister()`.
2023-05-03 11:27:25 +00:00
Pauli Virtanen
f7b57d87d6 bluez5: backend-native: fix off-by-one in at+xevent 2023-04-22 13:26:54 +03:00
Pauli Virtanen
87269e85db bluez5: AT+XEVENT input validation, cleanups & respond OK
Also support AT+XEVENT=BATTERY,%u which some devices apparently send.
2023-04-20 16:03:47 +00:00
delaosa
65ddd0a42b bluez5: Add battery level reporting via AT+XEVENT 2023-04-20 16:03:47 +00:00
Pauli Virtanen
772ff3365b bluez5: backend-native: add two missing OK HFP replies
We should reply OK to both AT+BIEV and AT+IPHONEACCEV.
2023-04-08 11:05:06 +00:00
Pauli Virtanen
282c7975fa bluez5: backend-native: fix getsockopt/fcntl error code handling 2023-03-19 21:33:28 +02:00
Pauli Virtanen
2bc48e1c18 bluez5: backend-native: make SCO acquire asynchronous
Don't block main loop in connect() for SCO sockets, as we can now do it
asynchronously.  Can be useful if connecting runs into problems.
2023-03-18 16:10:18 +02:00
Pauli Virtanen
4d844ee1c6 bluez5: backend-native: set state on synchronous acquire/release
Sinks/sources now expect transport state is set on acquire+release.
It doesn't need to be done async, so do it still synchronously.
2023-03-17 16:56:31 +00:00
Pauli Virtanen
fa3ee2e20b bluez5: allow disabling sink or source endpoints
Add option bluez5.roles that selects which endpoints (A2DP, BAP, HFP,
HSP) will be enabled.

This extends and deprecates bluez5.headset-roles.
2023-03-16 20:58:55 +02:00
Pauli Virtanen
da21cfa93c bluez5: backend-native: implement AT+BCC
Implement HF-initiated connection establishment command AT+BCC
for HFP AG.
2023-02-23 18:42:53 +02:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Pauli Virtanen
17049abd04 bluez5: backend-native: fixup HFP command handling
Strip initial \n from commands: some devices (Sennheiser HD 350BT) send
them.

Only reply OK to empty command with terminated command line;
non-terminated lines are invalid.

Add some debug in case the RFCOMM reply contains non-printable
characters.
2023-01-25 22:22:37 +02:00
Pauli Virtanen
effc1974e3 bluez5: backend-native: HFP should reply OK to no commands
HFP 1.8 -> 3GPP 27.007 -> ITU-T Rec. V.250 Sec. 5.6, which indicates to
reply OK to no commands on command line, not ERROR.
2023-01-25 19:35:26 +02:00
Pauli Virtanen
c7b3ef0d9f bluez5: backend-native: fix missing brace in CIND reply
It should look like ...,("battchg,(0-5)) not ...,"battchg",(0-5))
2022-12-21 12:55:20 +02:00
Barnabás Pőcze
14e044a92c spa: bluez: backend-native: fix filtered number memory leak
The `number_filtered` variable was dynamically allocated but never freed.
2022-11-14 16:15:21 +00:00
Dmitry Sharshakov
e0c9f87d78 bluez5: backend-native: prevent string overflow
Fixes -Wfortify-source when building
2022-11-13 15:13:33 +03:00
Dmitry Sharshakov
79b95e083a bluez5: backend-native: report HFP AG battery indicator to UPower 2022-11-07 16:32:17 +00:00
Frédéric Danis
fd508d395b bluez5: backend-native: Add a property to select the modem to use
By default no modem is allowed.
Property "bluez5.hfphsp-backend-native-modem" can be 'none', 'any' or the
modem device string has found in 'Device' property of
org.freedesktop.ModemManager1.Modem interface, e.g. for PinePhone
"/sys/devices/platform/soc/1c1b000.usb/usb2/2-1".
2022-10-05 19:31:50 +00:00
Frédéric Danis
47700a2214 bluez5: backend-native: Add battery level indicator support
This connect to the UPower service and update the +CIND battchg indicator
2022-10-05 19:31:50 +00:00
Frédéric Danis
a37aeac273 bluez5: backend-native: Add AT+VTS support
This allows to send a DTMF key on an active call.
2022-10-05 19:31:50 +00:00
Frédéric Danis
7c05574072 bluez5: backend-native: Add AT+CNUM support
This only support the first subscriber number.
2022-10-05 19:31:50 +00:00
Frédéric Danis
3566b0739b bluez5: backend-native: Add ATDdd...dd; support
This allows to dial a number.

Memory dialing (ATD>nnn...;) is not supported as it requests access to
the contact application.
2022-10-05 19:31:50 +00:00
Frédéric Danis
20572a1789 bluez5: backend-native: Add AT+CLCC support
This allows the HFP HF to retrieve the list of calls with their index,
state and remote number (if available).

This commit shared the list of calls between modemmanager.c and
backend-native.c, and switches call state storage from ModemManager
states to CLCC states
2022-10-05 19:31:50 +00:00
Frédéric Danis
55075915ec bluez5: backend-native: Add AT+CLIP support
This allows to send the caller number of an incoming call with the RING
event.
2022-10-05 19:31:50 +00:00
Frédéric Danis
4a89a13bda bluez5: backend-native: Support of ATA and AT+CHUP
Allow to answer, reject or terminate a call.

Answering or rejecting a call can only be done on an incoming call.
Terminating a call can only be done on active, dialing or alerting call.
2022-10-05 19:31:50 +00:00
Frédéric Danis
e9b82252f7 bluez5: backend-native: Add AT+CMEE support
Returns extended error report instead of just "ERROR" messages when
extended report has been activated by AT+CMEE=1 command.
2022-10-05 19:31:50 +00:00
Frédéric Danis
5b40ed62b4 bluez5: backend-native: Link with ModemManager Voice object
The Voice object lists the Call objects, which provides status of each call.

+CIND call indicator is set if at least one of the call is active.
+CIND callsetup indicator is set if one of the call is in ringing in or out
or dialing state.
2022-10-05 19:31:50 +00:00
Frédéric Danis
275d2bc603 bluez5: backend-native: Link with ModemManager Modem3GPP object
The Modem3GPP provides information about the network the modem is registered
to like the operator name and roaming status.
2022-10-05 19:31:50 +00:00
Frédéric Danis
13f0a0755e bluez5: backend-native: Link with ModemManager Modem object
The Modem object provides the own number (used by +CNUM), the network
service availability and signal strength (used for the +CIND).

+CIND indicators can be activated/deactivated using AT+BIA except for
call, callsetup and callheld indicators which should always reported.
All indicators are enabled on connection.
2022-10-05 19:31:50 +00:00
Pauli Virtanen
2e3347e850 bluez5: use HFP HF as default, not HSP HS
E.g. iphones don't support HSP, only HFP, so change the default to use
HFP HF instead of HSP.  HFP is now old, and most devices should support
it now.
2022-09-24 13:26:50 +03:00
Barnabás Pőcze
0a48165cff spa: bluez: backend-native: accept "=" for +VGS and +VGM
HFP 1.8 states in 4.35.1:

  Due to the small inconsistency between the GSM standard [2]) and the current
  Headset specification ([3]), the HF shall also accept the “=” symbol,
  in place of “:”, as a valid separator for this unsolicited result code.

iOS seems to use "=", so accept that as well.

See #2463
2022-09-24 02:47:58 +02:00
Barnabás Pőcze
0ee4fea03d spa: bluez: backend-native: fix HF/HS to AG message terminator
Both HFP and HSP require an AT command from HF/HS to AG to
be terminated by CR, not LF. (HFP 1.8, 4.34.1; HSP 1.2, 4.8.1)

See #2463

Fixes: 0b2d3730b6 ("bluez5: Add HFP HF support")
2022-09-24 02:45:41 +02:00
Barnabás Pőcze
2fb63f71c3 spa: bluez: backend-native: use sscanf() for parsing AT commands 2022-09-24 02:22:29 +02:00
Barnabás Pőcze
c24594a8ac spa: bluez: backend-native: fix type and add error checking 2022-09-24 02:22:19 +02:00
Barnabás Pőcze
8881030904 spa: bluez: backend-native: use strsep() instead of strtok()
`strsep()` is simpler to use than `strtok()` or `strtok_r()`
while being thread-safe and reentrant.

Although it is an extension, it is available in both glibc and musl.
2022-09-24 02:22:16 +02:00
Frédéric Danis
75ae86bf13 bluez5: backend-native: Only send one error message
When rfcomm_hfp_ag() returns false, an "ERROR" reply is sent.
When testing if the SLC is configured, 2 "ERROR" replies are sent, which
should not be done.
2022-09-16 12:32:12 +02:00
Pauli Virtanen
d82b3d6479 bluez5: backend-native: set HFP/HSP volume when connecting
The HFP/HSP HW volume on the device is not necessarily what we think it
is.

Sync the device volume to our value at connect time.
2022-07-09 18:19:45 +00:00
Barnabás Pőcze
f24250da66 spa: bluez: ignore unsupported indicators
Do not emit a warning when a known, but
otherwise unsupported indicator is received.

Fixes wireplumber#253
2022-05-10 12:09:18 +02:00
Barnabás Pőcze
15e7a61aa7 treewide: only define feature macros when the feature is available
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing

  if cond
    cdata.set('X', 1)
  endif

with

  cdata.set('X', cond)
2022-02-04 00:15:59 +01:00
Pauli Virtanen
a2a5012cb2 bluez5: backend-native: set transport volume on create
Initial transport volume was being set incorrectly to max for new
transports. This is usually masked by route restore, but not always.
2022-01-30 22:00:32 +02:00