Hello guys! In this video I’ll see you how toconnect your phone to Raspberry Pi via Bluetooth and how to add a Custom Trunk so that you’ll beable to spawn telephone calls use mobile channel. If you are here for the first time, my honour isThomas and one of the goals of this channel is to show you how to configure some VoIP relatedhardware and software and this video is actually 1 of 2 videos about exerting Asterisk mobilechannel. Today I will show you how to reach telephone calls expending your phone paired to Raspberry PiBluetooth Adapter and in the next one I will show you how to receive them on your headset. So let’sget started! At the very beginnings I will just tell you that we will not cover RasPBX installation because we have submerge that in our other videos and on our hotkey4 04 website, so if you need anyhelp with that, really follow those tutorials. Now, after logging into our RasPBX we willquickly check status of our bluetooth services and we will do this using “service bluetooth status”( this is quite obvious) and as you can see here, our service is active, it’s running and there’s some”sap move failed” but we don’t have to worry about that because we’re not going to use this.But whatwe have to do is to create our main config file. As you can see if we do “ls -l/ etc/ asterisk”we have a bunch of config records but there is no file announced chan_mobile.conf, so tocreate that we will do “cd/ etc/ asterisk” and here “touch chan_mobile.conf” to create the record and “chown asterisk: chan_mobile.com” datum to change the user, because as you can see all ofthose enters are owned by “asterisk” user and group.Then we will enter this datum with let’ssay “nano” – my favorite editor. So “nano chan_mobile.conf” and here we will definesome variables. We will need a[ general] area and now we will merely named “interval= 30 “( this is number of seconds between trying to connect to manoeuvres ). Then we will define ouradapter and for that we will need “id” and “address”( and this is going to be a MAC address of theadapter) and since we are going to use phone for outgoing ties, we will define “phone0″( you can have more of those) and we’ll characterize four variables: the authorities concerned will mounted “context”( and inFreePBX the most obvious will be “incoming-mobile” ), the authorities concerned will specified an “address”( and this is the mac addressof our phone) and we will gave “adapter” and “port”( this is rfcomm port that will be used toconnect to our telephone ). And you need to fill all those informations because if you don’t, ifwe enroll Asterisk console and do “module load chan_mobile.so”, as you can see weare unable to laden the module, because we have incorrect configuration of our main file. To fillall this necessary data we will use this “hcitool”. And at the very beginning we will do “hcitool dev”and it will expose the MAC address of our built-in bluetooth adapter in ourRaspberry Pi 4. Let’s just simulate this MAC address going to be home to our file and in[ adapter] sectionwe have this address and we will really paste this copied intelligence. and we have “id”. For “id”I recommend only consuming adapter honour which is “hci0”, however you can use any unique specify, you canplace let’s say “internaladapter”, basically … what it is you demand. It needs to be unique. Butfor simplicity I will just stay with “hci0”. After saving we will go back to using “hcitool scan”and this as it says will scan for all those compatible devicesthat have their bluetooth on and after a second we will find our iPhone.And once again wewill precisely duplicate the MAC address and going to be home to our config folder. Now with this emulated MAC address wewill complete the details on our phone0. So we will set an address, imitation the refer of our adapter( so ifyou set “id” of adapter “hci0” the authorities concerned will imitate the same ). And we don’t have information about the port sowe will just sit “1”, so that this module won’t propel a mistake. And after saving we can once againgo to our Asterisk console with “asterisk -rvvv”, do “module load chan_mobile.so” and voila – our module is loaded. Now after checking, if your phone can be discovered, we aregoing to do “mobile search” and this will take a few seconds and after a while you will see yourphone.And at the same time you will see a pop-up window on your telephone that’ raspbx’ tried to pairwith your maneuver, so accept the request. So we can see this MAC address of our phone, we can see thatthe “type” is phone and we have “port” and in our case it’s “8”. So we will once again exit our Asteriskconsole and supersede “1” with “8”. And now comes the touchy division: you probably have noticedthat our bluetooth machine phone0 has connected, it was initializing, but there was an error andit got disconnected. If you scan the internet you will find a few solutions for that. WhatI found that actually duties: it’s using “rfcomm”. And the authorities concerned will do “rfcomm bind 8 phoneMACaddress”. And what it does – this “rfcomm” command associatesthe paired device id with a serial manoeuvre list and so if we do “ls -l/ dev/ rf* “you will see this newly createddevice.So now going back to our Asterisk wewill do “core restart now” and after restart “mobile show devices” and you will see that ourphone is connected. If exploiting “rfcomm” doesn’t help, you might try restarting your Asterisk or evenrebooting the whole Raspberry. If this doesn’t help maybe you will have to do a google pursuit, because not every phone jobs the same way. So since we have our configuration labor, wecan do a test run and as I often do, we will do “channel originate portable/ phone0/ NUMBER application MusicOnHold” The amount is called andas you can seeit is ringing.If I rebuttal, the telephone get connected and it startsplaying this music on hold. So everything is ready, so we can disconnect and switch to ourweb browser to do the rest of the configuration. Now, after logging in, we will go to “Connectivity”> “Trunks”> “Add Trunk” and from this dropdown schedule we will “Add Custom Trunk”. As a trunk”Name” you can mount anything.I will just use “mobile_phone0”. We don’t need to set”Outbound CallerID”because this will be set by my SIM card carrier.And we will set “1” “Maximum channel”.We don’t need any directs in second tab.However in the third one: “Custom Settings”we need to set up “Custom Dial String” and this will look like: “mobile/ phone0 /$ OUTNUM$ “. Then after referring, we will see an error becausewe didn’t provided our Outbound CallerID but we don’t have to worry about that. Next we will go to”Outbound routes” and as a direction “Name” we can begin “mobile_phone0” and inour “Trunk Sequence”we will select this route that “weve created” a few seconds before that.In our “Dial Patterns” we will need to define when this route should be used( we have a niceexplanation how to use those structures ). In the most basic scenario, you can just go “ZX.”and this will allow you to call mostly anywhere. However it is worth considering whether thecost of mobile communications for a given route will be too high, so to restrict that I will usejust “ZXXXXXXXX” to call just local digits. Then we will touched “Submit” and our FreePBXconfiguration is ready. if we are to be able made “Apply Config” and research if all drives as it should.For testing intents I have logged in “1 00 ” extension and I will phone this 2277070 70( which is my officephone number) and you can see in a dialplan that it is connecting, this last wrinkle showsthat it is dialing this “mobile/ phone0/ 2277070 70 “. If I pick up, this channelis answered. With the “core show channels verbose” you can seeall the details about thisconnection. So everything is running smoothly. So as we said at the outset, you should knowhow to pair your phone to bluetooth adapter of your Raspberry Pi.In the next video, I will showyou how to create an extension and receive thosecalls on your headset. So I hope that members can enjoyedit, have a wonderful dayand see you next one ..