mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	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")
			
			
This commit is contained in:
		
							parent
							
								
									2fb63f71c3
								
							
						
					
					
						commit
						0ee4fea03d
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
					@ -259,6 +259,7 @@ static void rfcomm_free(struct rfcomm *rfcomm)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define RFCOMM_MESSAGE_MAX_LENGTH 256
 | 
					#define RFCOMM_MESSAGE_MAX_LENGTH 256
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* from HF/HS to AG */
 | 
				
			||||||
SPA_PRINTF_FUNC(2, 3)
 | 
					SPA_PRINTF_FUNC(2, 3)
 | 
				
			||||||
static ssize_t rfcomm_send_cmd(const struct rfcomm *rfcomm, const char *format, ...)
 | 
					static ssize_t rfcomm_send_cmd(const struct rfcomm *rfcomm, const char *format, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -279,7 +280,14 @@ static ssize_t rfcomm_send_cmd(const struct rfcomm *rfcomm, const char *format,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_debug(backend->log, "RFCOMM >> %s", message);
 | 
						spa_log_debug(backend->log, "RFCOMM >> %s", message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	message[len] = '\n';
 | 
						/*
 | 
				
			||||||
 | 
						 * The format of an AT command from the HF to the AG shall be: <AT command><cr>
 | 
				
			||||||
 | 
						 * - HFP 1.8, 4.34.1
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * The format for a command from the HS to the AG is thus: AT<cmd>=<value><cr>
 | 
				
			||||||
 | 
						 * - HSP 1.2, 4.8.1
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						message[len] = '\r';
 | 
				
			||||||
	/* `message` is no longer null-terminated */
 | 
						/* `message` is no longer null-terminated */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	len = write(rfcomm->source.fd, message, len + 1);
 | 
						len = write(rfcomm->source.fd, message, len + 1);
 | 
				
			||||||
| 
						 | 
					@ -293,6 +301,7 @@ static ssize_t rfcomm_send_cmd(const struct rfcomm *rfcomm, const char *format,
 | 
				
			||||||
	return len;
 | 
						return len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* from AG to HF/HS */
 | 
				
			||||||
SPA_PRINTF_FUNC(2, 3)
 | 
					SPA_PRINTF_FUNC(2, 3)
 | 
				
			||||||
static ssize_t rfcomm_send_reply(const struct rfcomm *rfcomm, const char *format, ...)
 | 
					static ssize_t rfcomm_send_reply(const struct rfcomm *rfcomm, const char *format, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -313,6 +322,18 @@ static ssize_t rfcomm_send_reply(const struct rfcomm *rfcomm, const char *format
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_debug(backend->log, "RFCOMM >> %s", &message[2]);
 | 
						spa_log_debug(backend->log, "RFCOMM >> %s", &message[2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * The format of the OK code from the AG to the HF shall be: <cr><lf>OK<cr><lf>
 | 
				
			||||||
 | 
						 * The format of the generic ERROR code from the AG to the HF shall be: <cr><lf>ERROR<cr><lf>
 | 
				
			||||||
 | 
						 * The format of an unsolicited result code from the AG to the HF shall be: <cr><lf><result code><cr><lf>
 | 
				
			||||||
 | 
						 * - HFP 1.8, 4.34.1
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * If the command is processed successfully, the resulting response from the AG to the HS is: <cr><lf>OK<cr><lf>
 | 
				
			||||||
 | 
						 * If the command is not processed successfully, or is not recognized,
 | 
				
			||||||
 | 
						 * the resulting response from the AG to the HS is: <cr><lf>ERROR<cr><lf>
 | 
				
			||||||
 | 
						 * The format for an unsolicited result code (such as RING) from the AG to the HS is: <cr><lf><result code><cr><lf>
 | 
				
			||||||
 | 
						 * - HSP 1.2, 4.8.1
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	message[0] = '\r';
 | 
						message[0] = '\r';
 | 
				
			||||||
	message[1] = '\n';
 | 
						message[1] = '\n';
 | 
				
			||||||
	message[len + 2] = '\r';
 | 
						message[len + 2] = '\r';
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue