Although the Audioengine B1 Bluetooth receiver is a pretty good one as far as Bluetooth receivers go, I'm not sure you really want to stream via Bluetooth as a replacement for your digital S/PDIF connection.
The best of the Bluetooth audio codecs, aptX, tops out at a bitrate of ~ 384kbps and is not lossless despite what some Bluetooth receiver vendors would have you believe.
Using one of the streaming devices you mentioned would allow you to stream losslessly via Wi-Fi and avoid the lower bitrate limitation of Bluetooth.
On the other hand, 40 feet is doable with a good quality coaxial S/PDIF cable and I currently have a 35 ft coaxial S/PDIF cable in use in a system. It doesn't have to be super expensive, just known good quality such as Belden 1694A cable with Canare RCAP "quasi" 75Ω connectors which can be had for ~ $50 in a 40ft length.
If you only have an optical S/PDIF connection, either a very high quality plastic or a glass fiber cable would be more appropriate for that distance. If one of the connections is a Mini-TOSLINK, avoid the use of a Mini-TOSLINK adapter and get a TOSLINK to Mini-TOSLINK cable.
Steve