PDA

View Full Version : Bluetooth headphone disconnected from zero w causes a serious problem



nimaazx
2019-01-15, 02:15
Hello everybody. As I mention that before I wanted to build a scenario that LMS play mp3 for many users.
I used picoreplayer. I read a lot about it. thank to developers.
I decided to use Bluetooth headphone instead of dac.
everything went well.
but there is a problem. when bluetooth headphone is disconnected from zero w other clients are disturbed. lms wants to being synced every client. I figured out latency of this zero w went high about 2000 ms when bluetooth disconnected.
I search for a solution. I think about useful script.

when the bluetooth headphone is going to be disconnected reboot RP zero w.
is it impossible?
i'm not familiar with bash scripting.
can you guide me please?
or other scenario that you think works.

chill
2019-01-15, 03:12
I would have thought it would be sufficient to power off the Bluetooth player (in LMS), rather than rebooting the RPi, before physically powering down the headphones, since players that LEAVE a synced group don't affect the other players in the group. I think you mentioned that this is in a 'language lab' environment. Do the users of the headphones have computers in front of them - could you install Squeezeplay to give them control and the ability to power down the device.

If they have computers with Squeezeplay then you wouldn't need the RPis, so I guess that's not the case. If it was, then wired headphones connected to those Squeezeplay instances might be easier to manage. Or you could even use an RPi that has a built in 3.5mm socket (e.g. a 3A+ rather than a Zero), so that you could use cheaper and simpler wired headphones.

However they connect, there will always be a momentary glitch while a synced player starts up. There is a SyncOptions plugin that seems to offer an option to 'wait for next track', so that this momentary glitch doesn't affect the others - not sure if it works with Squeezelite. But I suspect your 'language lab' MP3 is one long track, so this probably isn't appropriate.

Is it important that all the players are accurately synced, or do they just need to play the same track at about the same time? One option would be to somehow 'stream' your MP3 file (think of a digital radio broadcast), then leave the players unsynced. They will all play the stream at roughly the same time (apart from any pausing, rewinding etc), but they won't affect each other because they're not synced.

chill
2019-01-15, 04:19
Can you say a little more about the physical layout of your lab? Will the RPis all be in a bank close to the teacher (you?), or will they be close to each user? It would be possible to add one or more physical buttons to each RPi to handle some specific actions. If they're accessible by the users it might make sense to add a single button to each one, whose only function is to power OFF the player. I don't know for sure that such a function exists (I have a button that calls the 'power' function, which toggles the power on/off) but maybe an Off-only function exists. This would mean they could only be powered up again by someone with access to LMS, so interruptions to the other players could be controlled by the teacher.

Will you be sitting in front of a PC with access to the LMS web interface? If so, physical buttons would not be necessary, and you could control the power status of each player remotely. If you're set on Bluetooth headphones, they will probably power down automatically after a certain period of silence, so powering down the player should be sufficient.

nimaazx
2019-01-15, 12:12
Can you say a little more about the physical layout of your lab? Will the RPis all be in a bank close to the teacher (you?), or will they be close to each user? It would be possible to add one or more physical buttons to each RPi to handle some specific actions. If they're accessible by the users it might make sense to add a single button to each one, whose only function is to power OFF the player. I don't know for sure that such a function exists (I have a button that calls the 'power' function, which toggles the power on/off) but maybe an Off-only function exists. This would mean they could only be powered up again by someone with access to LMS, so interruptions to the other players could be controlled by the teacher.

Will you be sitting in front of a PC with access to the LMS web interface? If so, physical buttons would not be necessary, and you could control the power status of each player remotely. If you're set on Bluetooth headphones, they will probably power down automatically after a certain period of silence, so powering down the player should be sufficient.

sorry for my english writing.
thank a lot for your concern.
actually there is english lab.
we must run a system for their needs. I must use raspberry pi zero w for their price. in my country everything was going to be more expensive from 2 months ago.
pi zero w does not have dac. I bought pcm5102 and don't know exactly working in picoreplayer or not. as i mention bluetooth headphones and dac 5102 have same price.I suggest using bluetooth.
how ever there is no pc or powerful computer.
As you said internet radio streaming is another way. I worked with mixxx software and esp32 2 months ago.
esp32 does not have relaible harware and memory buffer.I left all of them.
about teacher and student.
teacher and student are end users. you idea is good but i supposed they are noob in IT field.

yesterday I was going to test my pc as a lms server and squeezelite client (together) (cmd command line enter squeezelite -s ip address)
and one zero w as another client with picoreplayer. when bluetooth headphones off pc client is going to be destroyed.
today i tested with two zero w bluetooth headphone. when one disconnected the other play well. but lms seekbar time player went backward and forward.

unfortunetly in this app and scenario there is one way to sync and start together.

I want to use streaming for maximum 50 clients.I think if one client battery of bluetooth headphones will be empty during the test ,not effect to others.
as well as i'm not sure it is working or not with a good pc server lms and High price access point for 50 clients. maybe use 2 server for them. or it is not reasonable.
Today I tested udp and rtp protocol with vlc on pc windows and android phone as a server and clients.
both of them have rupture between music sound.
I haven't tested tcp internet radio like mixxx software and icecast app server in raspberry.
i don't know it is tested in raspberry zero w or not. and do you know it is better that Squeezelite? is it an app or os for client in raspberry? I have heard about mpd in raspberry. do you know that supported bluetooth headphone or change audio output?
I don't need be synced exaclty , just start together. a few seconds delay not a problem.
just listen and not effect to others.
if bluetooth headphones can be used is perfect.

chill
2019-01-16, 02:33
I'm sure others can provide more authoritative comments, but I do suspect that using LMS to run 50 clients could be a problem. I've never tried that many, so can't say for sure.

To clarify some other points though:

My understanding of the Bluetooth issue you've experienced (when one set of headphones is turned off there is disruption to the other synced players) is that LMS thinks the 'player' is still 'on', it can't sync to it properly because the Bluetooth communication to that player is broken, so all the players are affected. As I see it there are two possible ways to avoid this.

1) Make sure the 'player' (in LMS) is turned off before the Bluetooth headphones are turned off. Turning off a player in a synced group does NOT disrupt the others. Once the player is off, the headphones can then be switched off - in fact they will probably turn themselves off automatically once they stop playing.

2) Don't sync the players. Set up a streaming source (e.g. in VLC), and get all players to play this stream via LMS. They won't be perfectly synced, but they'll be playing the same thing at the same time, like a radio station. I've never managed to get VLC streaming to work (from VLC on my Mac), but I believe this approach is possible. I suspect that a side-effect of this approach is that the load on the server *might* be reduced, because it's not trying to keep all 50 players synced. Not sure about that though.

The PC that you use to control the players (e.g. turn them on/off) does not have to be the same one that runs LMS. It just needs to open the LMS web page. So maybe you could have a powerful desktop running LMS (Would that help with running 50 players? Not sure), but a less powerful laptop to control the players.

chill
2019-01-16, 06:10
Thinking about this further, I can't help feeling that managing 50 identical sets of Bluetooth headphones is going to be a headache. They'll all show up with the same Bluetooth name, so associating a specific set with a specific RPi, and keeping them correctly associated, might be confusing.

I wonder if the money you could save by buying cheap wired headphones instead could be put towards using the Pi 3A+ instead of the Pi Zero w (approx 2x the price). I think wired headphones would be more robust, would not need charging, pairing, connecting each time. So you'd save a lot of staff time and effort too.

On the question of using more than one LMS installation to service 50 players, the streaming approach would mean that you could indeed split the players between different LMS installations - just connect every player to the same stream. Just a hunch - maybe 5x RPi 3B+, each handling 10 players, would work. Or 10x RPi with 5 players each. Costwise: 10x 3B+ = ~300, plus 50x 2B+ =~1200 = 1500 total.

nimaazx
2019-01-16, 07:48
I'm sure others can provide more authoritative comments, but I do suspect that using LMS to run 50 clients could be a problem. I've never tried that many, so can't say for sure.

To clarify some other points though:

My understanding of the Bluetooth issue you've experienced (when one set of headphones is turned off there is disruption to the other synced players) is that LMS thinks the 'player' is still 'on', it can't sync to it properly because the Bluetooth communication to that player is broken, so all the players are affected. As I see it there are two possible ways to avoid this.

1) Make sure the 'player' (in LMS) is turned off before the Bluetooth headphones are turned off. Turning off a player in a synced group does NOT disrupt the others. Once the player is off, the headphones can then be switched off - in fact they will probably turn themselves off automatically once they stop playing.

2) Don't sync the players. Set up a streaming source (e.g. in VLC), and get all players to play this stream via LMS. They won't be perfectly synced, but they'll be playing the same thing at the same time, like a radio station. I've never managed to get VLC streaming to work (from VLC on my Mac), but I believe this approach is possible. I suspect that a side-effect of this approach is that the load on the server *might* be reduced, because it's not trying to keep all 50 players synced. Not sure about that though.

The PC that you use to control the players (e.g. turn them on/off) does not have to be the same one that runs LMS. It just needs to open the LMS web page. So maybe you could have a powerful desktop running LMS (Would that help with running 50 players? Not sure), but a less powerful laptop to control the players.

thank you for your information.
about limitation i think nobody tested it for 50 clients. I asked before but nobody was sure.

about number 1 you said,
It is supposed that the battery of bluetooth headphone is low and powered off Suddenly.
and actually we dont want a teacher and student do something during disconnecting.

number 2 : Yes you right, I think I have to test it. once i tested vlc as server and vlc player as clients in windows with udp protocol.
or before that i have worked with mixxx and icecast.
I did not know that lms can be used like internet radio streaming. where is that option?
for this purpos what application or os do i use in client side?

As well as i dont have info about what you said.it is a little strange.
run lms server in one server and run webpage of lms in other pc. I don't think it is related for managing.supporting many clients like 50 i think it is supported by The developers and socket programming that they use .

Tomorrow i tested 3 and 4 raspberry pi with just bluetooth headphone. and I disconnected one or two.
or I will use one RPi 3 B+ with dac as a client that others to be synced with.maybe it makes differce.

if they are not work using streaming method.
if you know tell me where the streaming setting is in lms ?

nimaazx
2019-01-16, 08:05
Thinking about this further, I can't help feeling that managing 50 identical sets of Bluetooth headphones is going to be a headache. They'll all show up with the same Bluetooth name, so associating a specific set with a specific RPi, and keeping them correctly associated, might be confusing.

I wonder if the money you could save by buying cheap wired headphones instead could be put towards using the Pi 3A+ instead of the Pi Zero w (approx 2x the price). I think wired headphones would be more robust, would not need charging, pairing, connecting each time. So you'd save a lot of staff time and effort too.

On the question of using more than one LMS installation to service 50 players, the streaming approach would mean that you could indeed split the players between different LMS installations - just connect every player to the same stream. Just a hunch - maybe 5x RPi 3B+, each handling 10 players, would work. Or 10x RPi with 5 players each. Costwise: 10x 3B+ = ~300, plus 50x 2B+ =~1200 = 1500 total.

thank you again.about using dac i know there is a straight way. but i can figure out how to be recognized it to picoreplayer.
my dac is pcm5102 3$ module .

connection wiring was ok but i will try it again.
about using rp3 for client. unfortunately the price is double in my country and in my situtation it is not reasonable.
in other country it is the better way than using zero w.

about using RPi 3B+ , is it possible using as server?
for play music and sync client , what os should be used? raspberrian or picoreplayer has server side? I think I saw something but never test it.
fortunately we can use with hdmi output to monitor. but I have not known that which scenario is relaible? it is or streaming internet radio.
thank you again.

chill
2019-01-17, 02:02
number 2 : Yes you right, I think I have to test it. once i tested vlc as server and vlc player as clients in windows with udp protocol.
or before that i have worked with mixxx and icecast.
I did not know that lms can be used like internet radio streaming. where is that option?
for this purpos what application or os do i use in client side?


I've never used this option myself, but I believe the 'Tune in URL' option, in the 'Radio' menu of LMS, is where you would connect a player to a local stream. Maybe others who've used this option could comment. And clearly, if you're going to use this option on the LMS server side, then the clients would be LMS 'players'.



As well as i dont have info about what you said.it is a little strange.
run lms server in one server and run webpage of lms in other pc.

Yes, that's how LMS works - use a browser on any device to access <server IP address>:9000



about using RPi 3B+ , is it possible using as server?
for play music and sync client , what os should be used?

Use piCorePlayer to set up the 3B+. Use the web interface of pCP to setup and configure LMS as the server (you can also configure a Squeezelite 'player' on the same unit if you wish).
Use piCorePlayer to set up the Zero W. Use the web interface of pCP to configure Squeezelite so that the Zero W can act as a client 'player'. In this scenario, you would not configure LMS on the Zero W.

So my thoughts would be to:
- Get 'a number' of RPi3B+ units, and use pCP to install LMS on each one to act as servers.
- On your 50 Zero W units use pCP to configure Squeezelite, so that you have 50 players.
- Connect each player to one of the servers. The number of RPi3B+ units that you'd need would depend on the maximum number of players that work reliably on each server.
- Point each player to the locally streamed MP3 file. Don't attempt to synchronise the players, but rely on the fact that the stream will be like a radio station. This should prevent Bluetooth issues on one player from disrupting the playback on other players.

This is all speculation on my part - what do others think of this approach?

chill
2019-01-17, 02:44
thank you again.about using dac i know there is a straight way. but i can figure out how to be recognized it to picoreplayer.
my dac is pcm5102 3$ module .


If you don't mind a little soldering (x50) there is another (cheap) way to add a 3.5mm audio jack to a Pi Zero W - see here (https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/overview). I might try this out myself.

If it was me, I'd do anything to avoid having to manage 50 sets of Bluetooth headphones. :)

utgg
2019-01-17, 04:08
about limitation i think nobody tested it for 50 clients. I asked before but nobody was sure.

Can you actually buy 50 Pi Zero Ws in your country? I believe there is a still a rule of one purchase per customer at the $10 price.

Paul Webster
2019-01-17, 04:17
If it was me, I'd do anything to avoid having to manage 50 sets of Bluetooth headphones. :)
Silent disco?

chill
2019-01-17, 05:40
Can you actually buy 50 Pi Zero Ws in your country? I believe there is a still a rule of one purchase per customer at the $10 price.

I wonder if the OP counts as an educational establishment - I assume there are options for buying multiple units for schools etc. Wasn't the RPi targeted at classrooms, at least initially?



Silent disco?
Interesting idea - I wonder what it takes to run one of those.

Paul Webster
2019-01-17, 07:10
Interesting idea - I wonder what it takes to run one of those.

I think professional ones use a radio channel and special headphones or an adapter. My comment was a bit of a joke but it might work for a small number of receivers that are fairly close to the source.
No idea if there is enough capacity for 50 Bluetooth receivers to work at the same time and close together.

d6jg
2019-01-17, 09:57
I think professional ones use a radio channel and special headphones or an adapter. My comment was a bit of a joke but it might work for a small number of receivers that are fairly close to the source.
No idea if there is enough capacity for 50 Bluetooth receivers to work at the same time and close together.

On the contrary I think the technology used for a silent disco is exactly what the OP is after

These guys hire stuff out but provide a how it works article
https://www.silentdiscodirect.co.uk/how-it-works/

I suspect these are RF headphones - like Sennheiser RS120's

Paul Webster
2019-01-17, 10:41
On the contrary I think the technology used for a silent disco is exactly what the OP is after

These guys hire stuff out but provide a how it works article
https://www.silentdiscodirect.co.uk/how-it-works/

I suspect these are RF headphones - like Sennheiser RS120's

Exactly ... not bluetooth.

nimaazx
2019-01-19, 10:37
I've never used this option myself, but I believe the 'Tune in URL' option, in the 'Radio' menu of LMS, is where you would connect a player to a local stream. Maybe others who've used this option could comment. And clearly, if you're going to use this option on the LMS server side, then the clients would be LMS 'players'.

Yes, that's how LMS works - use a browser on any device to access <server IP address>:9000


Use piCorePlayer to set up the 3B+. Use the web interface of pCP to setup and configure LMS as the server (you can also configure a Squeezelite 'player' on the same unit if you wish).
Use piCorePlayer to set up the Zero W. Use the web interface of pCP to configure Squeezelite so that the Zero W can act as a client 'player'. In this scenario, you would not configure LMS on the Zero W.

So my thoughts would be to:
- Get 'a number' of RPi3B+ units, and use pCP to install LMS on each one to act as servers.
- On your 50 Zero W units use pCP to configure Squeezelite, so that you have 50 players.
- Connect each player to one of the servers. The number of RPi3B+ units that you'd need would depend on the maximum number of players that work reliably on each server.
- Point each player to the locally streamed MP3 file. Don't attempt to synchronise the players, but rely on the fact that the stream will be like a radio station. This should prevent Bluetooth issues on one player from disrupting the playback on other players.

This is all speculation on my part - what do others think of this approach?


Hello Chill. it seems more reliable than that. I guess I know how it is working. there is a application named Icecast. it is for configuring streaming. it must be run on server side. behind that we need an app named MIXXX. It connects to icecast server and acts like an Player App. after that I need to enter the url of Icecast x.x.x.x:8000/music in Logitech media server.
one thing I don't understand exactly. as you said for a clients side for internet radio streaming method i need to use "LMS player". you mean that using other than picoreplayer or squeeze lite?
maybe it does not need set setting or change something in client side picoreplayer for streaming.



Use piCorePlayer to set up the 3B+. Use the web interface of pCP to setup and configure LMS as the server (you can also configure a Squeezelite 'player' on the same unit if you wish).
Use piCorePlayer to set up the Zero W. Use the web interface of pCP to configure Squeezelite so that the Zero W can act as a client 'player'. In this scenario, you would not configure LMS on the Zero W.

So my thoughts would be to:
- Get 'a number' of RPi3B+ units, and use pCP to install LMS on each one to act as servers.
- On your 50 Zero W units use pCP to configure Squeezelite, so that you have 50 players.
- Connect each player to one of the servers. The number of RPi3B+ units that you'd need would depend on the maximum number of players that work reliably on each server.
- Point each player to the locally streamed MP3 file. Don't attempt to synchronize the players, but rely on the fact that the stream will be like a radio station. This should prevent Bluetooth issues on one player from disrupting the playback on other players.

This is all speculation on my part - what do others think of this approach?


if I understand what you said.some parts is not clear for me. in This Scenario other than streaming radio URL (x.x.x.x:8000/stream),
You says :
1- put 3 RPi 3B+ for server side.
2-put 50 zero w for clients
3-connect them to each server . depends on supported counts that each server can.
4- point each player to streamed local file! how can it be done ? sometime I saw that when picoreplayer run and clicked in Play button in front of GUI page it played a mp3 file that I synced for players before. in this situation I think we don't have a control of playing. and it necessary to connect to gui and click play for each player. am i wrong ?

as well as there is a challenge for end user.they should play them easily and maybe it is complex. I have not tested this method yet.
I think other method you said first maybe is more reliable. streaming from internet radio server. in this method I just figure it out how to connect clients to LMS tune in radio. as i said maybe it is not necessary to change setting. clients stream automatically without changing anything.



If you don't mind a little soldering (x50) there is another (cheap) way to add a 3.5mm audio jack to a Pi Zero W - see here (https://learn.adafruit.com/adding-basic-audio-ouput-to-raspberry-pi-zero/overview). I might try this out myself.

If it was me, I'd do anything to avoid having to manage 50 sets of Bluetooth headphones. :)


I appreciate you for searching. 2 days ago I found something a very cheap method for that ,even in my country :D
This one (https://www.alibaba.com/product-detail/Audio-5-1-USB-Sound-Card_60581093555.html?spm=a2700.7724857.normalList .74.8a9321eafjHbML).:D

I liked to share it with you. It is worked and it is very strange for me. Thanks to developers of Picoreplayer and Raspbian OS. I tested pcm5102 again and I found that I forgot to connect xmt pin to 3.3V for being unmute :o

both of them are working. i think using usb dac is better for their price. I just need to open it up and connect it with OTG-USB to Zero w and put them in a case.
Bluetooth option is an option may that works or not. I really agree with you about Bluetooth pairing , Frequency and name interference or disturbing other players.
In my latest test I tested Bluetooth with 2 zero w and BL headphones. do not disturb each other during playing when one disconnected.But lms seekbar time of music went became crazy.I strongly think when Clients Side are similar about softwares and hardwares , this disturbing is changed. I tested another scenario once before with squeezelite on my windows 10 PC and one PCP in zero w and the result was Disaster.

nimaazx
2019-01-19, 10:55
Can you actually buy 50 Pi Zero Ws in your country? I believe there is a still a rule of one purchase per customer at the $10 price.


Hey. finally we should buy them if we want to implement this project but at this moment we can't.at this moment I Have to get result with 4 or 5 for prototype.
I live in IRAN.Unfortunately, after the last USA sanctions , The price of all things has multiplied. For example, the price of RPi 3B+ is doubled and our markets are not connected to other online shopping centers in the world.

nimaazx
2019-01-20, 02:18
On the contrary I think the technology used for a silent disco is exactly what the OP is after

These guys hire stuff out but provide a how it works article
https://www.silentdiscodirect.co.uk/how-it-works/

I suspect these are RF headphones - like Sennheiser RS120's

HI. I searched about this headphones.
https://sennheiserusa.happyfox.com/kb/article/171-how-do-i-add-additional-headphones-to-a-rs-120-wireless-headphone-system/

they are using RF . it seems each headphone can be tune with other base station. for example using one station with many headphones.no problem. I don't know they can be purchased individually without base station. it seems it can be done but not in my country.
I think there is no limitation for this type of headphones with one stations. I don't know exactly. for this situation better using RF. because using TCP and WIFI like my project, need handshake steps.they always works with system that have bandwidth.
for Bluetooth technology , there is a pair to pair method. no product support broadcast or multicast right now.
I think there will be a Bluetooth multicast system or like that in future. Qualcomm are working for this project as they said.

https://www.qualcomm.com/news/releases/2018/02/21/qualcomm-broadcast-audio-helps-users-stream-music-numerous-bluetooth

drmatt
2019-01-29, 08:36
What a genius use of LMS. Did Logitech ever consider marketing it in this arena?!


Transcoded from Matt's brain by Tapatalk