HFP profile with linux and iphone 5 - iphone

how can I use hfp on my ubuntu linux with iphone 5s? I have bluetoooth, all bluez packages and ofono installed.
For ofono I need a modem. From what I understood from bluetooth core, protocoll and profile specification, rfcomm and spp of bluetooth can be used to emulate a modem. How does this work with bluez? Do the bluetoothd and ofonod dbus-services already handle incoming connections to hfp oder do I have to write my own listener?
EDIT:
The program is running. I implemented it according to the test-scripts. But I am experiencing audio issues, as I don't have any sound when performing calls. The sound is not muted.
pa log (translated):
Sep 26 13:57:47 ubu2 pulseaudio[2524]: [alsa-sink-Intel ICH]
alsa-sink.c: ALSA woke us up to write new Data on the Device but there
was nothing to write! Sep 26 13:57:47 ubu2 pulseaudio[2524]:
[alsa-sink-Intel ICH] alsa-sink.c: This is most probably an Error of
the ALSA-Driver 'snd_intel8x0'. Please send this error to the
ALSA-Developers. Sep 26 13:57:47 ubu2 pulseaudio[2524]:
[alsa-sink-Intel ICH] alsa-sink.c: We have been woken up by the
POLLOUT-Set, but a following call of snd_pcm_avail() returned the
value 0 or another value smaller than min_avail.
How can I see if ALSA has encountered some errors? I found no log.
When connecting the a2dp-Profile so that my computer are the speakers of the iPhone I also have no sound.
EDIT 2:
To solve this error, this is recommended:
File: /etc/pulse/default.pa
Add tsched=0 to the following line:
load-module module-detect
from post #21 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/374002
But it does not solve my issue. I try force-loading the also modules too.

Having ofono and bluez should be enough.
However, latest version of bluez/ofono and pulseaudio don't support HSP and HFP profiles.
Pulseaudio release notes say that only A2DP is supported with bluez5.x. If you are using
bluez4.x, ofono and pulseaudio 4.x/5.x you might still get this working without a problem.
http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/
ofono will treat your iPhone 5s as your modem. Once you get the iPhone paired and connected
through bluetoothctl or any alternative GUI, you could run the following ofono tests to see
if ofono picked it up right. Try running ofonod using ofonod -n -d on a terminal to monitor the debug log and probably run pulseaudio in verbose too (pulseaudio -k && pulseaudio -v)
bash$ cd */ofono-1.x/test
This directory contains sample dbus scripts to test the ofono functionalities.
bash$ ./list-modems
[ /hfp/org/bluez/hci0/dev_94_94_26_88_XX_XX ]
Type = hfp
Interfaces = org.ofono.Siri org.ofono.VoiceCallManager org.ofono.CallVolume org.ofono.Handsfree org.ofono.NetworkRegistration
Features = net
Serial = 94:94:26:88:XX:XX
Online = 1
Powered = 1
Lockdown = 0
Emergency = 0
Name = XXXXXX’s iPhone
[ org.ofono.Siri ]
EyesFreeMode = disabled
Enabled = 1
[ org.ofono.VoiceCallManager ]
EmergencyNumbers = 08 000 999 110 112 911 118 119
[ org.ofono.CallVolume ]
Muted = 0
SpeakerVolume = 50
MicrophoneVolume = 50
[ org.ofono.Handsfree ]
VoiceRecognition = 0
InbandRinging = 1
Features = three-way-calling echo-canceling-and-noise-reduction voice-recognition release-all-held release-specified-active-call private-chat create-multiparty
BatteryChargeLevel = 4
SubscriberNumbers = +XXXXXXXXXXXX
EchoCancelingNoiseReduction = 1
[ org.ofono.NetworkRegistration ]
Status = registered
Name = XXX XXXXXX
Mode = auto-only
Strength = 60
If you see output similar to above, enable the modem and try dialling using the following
command and observe ofono debug log if SCO socket is created or rejected. And, of course,
see if the audio is routed to Ubuntu.
bash$ ./enable-modem
bash$ ./dial-number +XXXXXXXXXXXX
...
Similarly, try calling up your iPhone and observe the ofono, pulseaudio logs.
bash$ ./answer-calls
Looks like folks at pulseaudio are trying to get this working with bluez5.x and ofono but
there doesn't seem to be a patch available publicly yet. The bug is being tracked here:
https://bugs.freedesktop.org/show_bug.cgi?id=73325

HFP for Linux is a Bluetooth Hands-Free Profile server.
It allows your Linux system to act as a speakerphone for your mobile phone. It aims to be a compliant Bluetooth HFP 1.5 Hands Free implementation, supporting all required commands and notifications, as well as streaming audio.
http://nohands.sourceforge.net/

Related

Can I transmit serial data only using a data cable via Raspberry pi 0 w's USB port?

I have been recently trying to find out a way whether I can send serial data (large file like image data) only through the Rpi w 0's micro USB port using ttyGS0. But when I searched online I only found ways of setting up headless through serial and other stuff which was no what I wanted. But I did follow the tutorial half way
I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line
I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space
Thinking I could just use the /dev/ttyGS0 in my serial program on the Rpi and send the data the data was being sent but on my PC when I tried to access my Rpi which was on comport 12 it said port not found and couldn't open it. But it was showing up in the device manager as 'PI USB to Serial(COM12)'
Then I wondered whether it would be possible at all to access Rpi's com port this way.
If that's the case, I want to know if there is any other way to access the Rpi's USB port only using the USB cable
Note
I don't want to use Rpi's USB as a way of logging ie. 'headless setup'. I just want to receive serial data like an Arduino.
I don't want to use the GPIO pins (I tried) as they can only send limited characters at a time and I want to send an image file. Very quickly.
I don't have any serial converters at hand so i could route it to the arduino and use /dev/ttyUSB0
then read it on PC. I just only want to use the USB cable.
In case this info is required:-
my pc is a probook 6560b running windows 7
things i found while testing and stuff:-
I did do -lsusb command but i dint find my device on that list
I tried the 'ls /dev/ttyGS0' and i found '/dev/ttyGS0'
I checked many forums and some guys were asiking to use this command 'dmesg | grep tty'and show them the code . So i performed it i dont understand what alot in the piece of text means but if it would be helpfull i pasted it here:-
pi#aloypi:~ $ dmesg | grep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[ 0.001496] printk: console [tty1] enabled
[ 2.543414] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[ 2.561791] 20215040.serial: ttyS0 at MMIO 0x20215040 (irq = 53, base_baud = 50000000) is a 16550
[ 6.716694] systemd[1]: Created slice system-getty.slice.
i also tried this one 'dmesg | grep dwc2' out of curiosity and got this but i cant say anything judging it so ya
pi#aloypi:~ $ dmesg | grep dwc2
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[ 2.379190] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 2.386185] dwc_otg: FIQ enabled
[ 2.386205] dwc_otg: NAK holdoff enabled
[ 2.386219] dwc_otg: FIQ split-transaction FSM enabled
[ 2.386245] Module dwc_common_port init
[ 2.968203] modules-load=dwc2,g_serial
[ 8.344134] dwc2 20980000.usb: supply vusb_d not found, using dummy regulator
[ 8.367130] dwc2 20980000.usb: supply vusb_a not found, using dummy regulator
[ 8.626751] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[ 8.647109] dwc2 20980000.usb: DWC OTG Controller
[ 8.653810] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[ 8.726672] dwc2 20980000.usb: irq 33, io mem 0x20980000
[ 8.787097] usb usb1: Manufacturer: Linux 5.10.17+ dwc2_hsotg
[ 9.371395] dwc2 20980000.usb: bound driver g_serial
[ 194.158373] dwc2 20980000.usb: new device is high-speed
[ 194.189677] dwc2 20980000.usb: new device is high-speed
[ 194.225164] dwc2 20980000.usb: new address 3
Ok looks like i made some progress
till now I did this
I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line
I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space
I did this 'sudo nano /etc/rc.local' and placed 'modeprobe g_serial use_acm=0' before 'exit 0'
Then i performed this command 'sudo systemctl stop getty#ttyGS0.service'
and then this 'sudo systemctl disable getty#ttyGS0.service'
(i think disabling getty#ttyGS0.service and puting 'modeprobe g_serial use_acm=0' in the folder metioned above allowed rpi and pc to comunicate but then again i can be wrong )
then perfored a 'sudo reboot'
this seemed to solve my problem
but i have one more problem now
whatever is sent from the rpi i can only recieve in the coolterm serial port reading software
i cant seem to use read the port from processing for some reason
(im using processing to later read the image file being sent)
here is my current serial reading program in processing
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup()
{
myPort = new Serial(this, "COM13", 115200);
}
void draw()
{
if ( myPort.available() > 0)
{ // If data is available,
val = myPort.readStringUntil('\n'); // read it and store it in val
}
if (val!=null)
{
println(val); //print it out in the console
}
}
i kinda am stuck here :P
EDIT
welp nevermind i solved it
i finally finally got it working yaaaaaaaayyy
OK now remember all who seek for the answer when using /dev/ttyGS0 it uses the CTS and RTS protocall
(now idk if it can be disabled but please lemme know you guys)
Its like the pi asks your pc wether it is cleared to send the data and when the pc says yeah ok send the data the pi sends it
so whenever your using this method please enable rts or cts
this is what i used in processing to recieve the data
import processing.serial.*;
Serial myPort;
void setup()
{
//remember to set the COM port to which your pi is set
size(200, 200);
myPort = new Serial(this, "COM13", 115200);
}
void draw()
{
if ( myPort.available() > 0)
{
if(myPort.getCTS()==true){
myPort.setRTS(true);
print(myPort.read());
}
}
}
i hope this is of loadsa help to you guys but if there is some correction needed please lemme know yall:D
thanks

Raspberry PI 4 + Huawei E3372 - Send AT commands

I'm trying to send AT commands to a Huawei E3372 USB Dongle but I haven't figured out how to mount correctly.
If I do lsusb, I get the following:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 001 Device 003: ID 03f0:034a HP, Inc Elite Keyboard
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The dongle is listed, I can also access it's configuration screen on 192.168.1.1 and I can access internet.
I have tried creating the config file:
sudo nano /etc/usb_modeswitch.d/12d1:14db
and entered the following configuration
TargetVendor=0x12d1
TargetProduct=0x14db
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
NoDriverLoading=1
I have tried various configurations found on the web but none seems to work.
/dev/tty /dev/tty19 /dev/tty3 /dev/tty40 /dev/tty51 /dev/tty62
/dev/tty0 /dev/tty2 /dev/tty30 /dev/tty41 /dev/tty52 /dev/tty63
/dev/tty1 /dev/tty20 /dev/tty31 /dev/tty42 /dev/tty53 /dev/tty7
/dev/tty10 /dev/tty21 /dev/tty32 /dev/tty43 /dev/tty54 /dev/tty8
/dev/tty11 /dev/tty22 /dev/tty33 /dev/tty44 /dev/tty55 /dev/tty9
/dev/tty12 /dev/tty23 /dev/tty34 /dev/tty45 /dev/tty56 /dev/ttyAMA0
/dev/tty13 /dev/tty24 /dev/tty35 /dev/tty46 /dev/tty57 /dev/ttyprintk
/dev/tty14 /dev/tty25 /dev/tty36 /dev/tty47 /dev/tty58
/dev/tty15 /dev/tty26 /dev/tty37 /dev/tty48 /dev/tty59
/dev/tty16 /dev/tty27 /dev/tty38 /dev/tty49 /dev/tty6
/dev/tty17 /dev/tty28 /dev/tty39 /dev/tty5 /dev/tty60
/dev/tty18 /dev/tty29 /dev/tty4 /dev/tty50 /dev/tty61
No more luck with dmesg | grep ttyUSB that returns nothing (same for USB0, USB1,...)
It's probably something wrong in the config file but I don't see exactly what needs to be done.
Any idea ?
Thanks!
You attach wrong lsusb output. The dongle is not listed.
Perhaps the device code 14db and accessible 192.168.1.1 looks like your modem is switched to newest mode where the dongle looks like router. If you would like to send AT command then you must change mode to serial. First of all try it through:
/etc/usb_modeswitch.conf
The last part of the file contain your desired option:
HuaweiAltModeGlobal=0
Notice the comment above this option:
...you can globally set an alternative method here which provides a
different mode: either plain serial PPP...
Just try to change number. There should be around 6 modes and one of them will switch your dongle to serial mode.
Best luck.

Atollic couldn't verify ST device?

trying to program and debug STM32F103 (Bluepill) from Atollic TrueStudio 9.3 I got following message:
STMicroelectronics ST-LINK GDB server. Version 5.1.0 Copyright (c)
2018, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
Vendor = 0x55
Error in initializing ST-LINK device. Reason: ST-LINK: Could not
verify ST device! Abort connection.
Trying to do the same thing in St-Link utility works without any problems (also erasing and programming):
What could be the problem with this, why does it have problems with verification ?
Tnx for helping in advance!
The problem is that the ID of the STM32F103 on the BluePill and the ID, defined the debugger config files are different. Often the BluePills have counterfeit ICs on them in order to keep the price low, but these do not have the same ID as genuine ICs.
The Instructions/video below are made for STM32CubeIDE however they should also work for TrueSTUDIO.
Video about a workaround: https://youtu.be/bJYp8o7FoYo
Open the Debug Configuration Window
Select ST-LINK(OpenOCD) in the Debug Probe Dropdown
Search stm32f1x.cfg file the C:\ST\STM32CubeIDE_1.2.0\STM32CubeIDE and open it using notepad.
Search for this Line
Now change the ID from 0x1ba01477 to 0x2ba01477 as shown here
Save the file, now debugging should work
this solution also works for clone chips like CH32F103 which is in some cases on BluePill
the other solution is to change a parameter in "stm32f1x.cfg"
open it with a text editor and find this line:
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
change "$_CPUTAPID" to zero at the end of line it should be like this:
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0
after that :Open the Debug Configuration Window like picture above and choose "Select ST-LINK(OpenOCD)" in the Debug Probe Dropdown
then click "Show generator options…” and in Mode setup change"Reset Mode”For“Software system reset”.
both of ways works and i've tested them with CubeIDE and CH32f103c8t6.
remember to change jumper on board
jumpers : up = 0 ; down = 1

openocd **Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED**

I am trying to setup a eclipse development environment to work with stm32f303 nucleo 32 board.
http://www.st.com/en/evaluation-tools/nucleo-f303k8.html
So far, the all the tools seems to be correctly installed and working: I have succefully compiled and started openocd debugger for stm32f4 discovery and when I connect stm32f303 nucleo 32 board and start openocd, the led on the board indicates that it is connected. (I have flashed the board.)
The thing is openocd get lost when I do step by step debugging and this seems related to the message openocd gives me when started (look for bold line):
Open On-Chip Debugger 0.9.0 (2015-05-19-12:09)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
**Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED**
Info : STLINK v2 JTAG v27 API v2 SWIM v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.239293
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
Does someone know how to fix usb driver in that case, or it is possible that something else cause the problem?
In case you experience this issue on Linux, you have to configure udev rules to work with the device. Find the 99-openocd.rules included with the source distribution of openOCD under Contributions. Connect your ST-Link USB-device and run 'lsusb' from a terminal, it will list something like this:
Bus 004 Device 009: ID 0483:3748 STMicroelectronics ST-LINK/V2
Notice the value behind ID, you want to check the 99-openocd.rules to see if there is a matching entry supporting the device, in the above case it's this one:
# STLink v2
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="664", GROUP="plugdev"
Copy this file to your /etc/udev/rules.d configuration directory and reboot your machine. Then try debugging again.
The OpenOCD distribution includes some libusb drivers, and recommends to run the zadig.exe tool to activate them. This will solve your problem.
http://zadig.akeo.ie/
As #silverdr mentioned in the comments, disconnecting the device and reconnecting it worked for me.

HCI LE Connection -- Command Disallowed

I am using noble & bleno via node.js to connect to a BLE peripheral from Rasbian, yet something goes wrong and the connection can not be made. I tried multiple different BLE dongles and they all fail the same way. Currently I have a CSR 4.0 attached.
The connections works just fine when being made from OS X, iOS or Android.
Here is the HCI Dump:
2015-11-22 18:36:54.732907 < HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr 00:12:6F:6B:C7:32 type 0
interval 96 window 48 initiator_filter 0
own_bdaddr_type 0 min_interval 6 max_interval 12
latency 0 supervision_to 200 min_ce 4 max_ce 6
2015-11-22 18:36:54.734511 > HCI Event: Command Status (0x0f) plen 4
LE Create Connection (0x08|0x000d) status 0x0c ncmd 1
Error: Command Disallowed
Now when I try a connection via hcitool lecc or gatttool the connection is made - yet trying to write characteristic values fails with Characteristic Write Request failed: Attribute requires authentication before read/write. Is this related?
I am on Linux raspberrypi 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux
Unfortunately even security-level high or medium didn't help.
The issue was, that I had a connection from a Central (RPi is Peripheral) and I wanted to connect to another Peripheral, which would put the RPi into Central mode. Apparently this doesn't work with BlueZ.
So I ended up with using 2 Bluetooth Dongles.
If you are looking for another OS: Mac OS X does support this though.
Also I was told that Bluetooth 4.1 Dongles might work with this.