View unanswered posts | View active topics


Reply to topic  [ 117 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next
Author Message
  
 Post subject: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Sun Oct 09, 2016 7:57 am 
Registered User

Joined: Jun 2016
Posts: 26

Offline
Hi,

after I get some questions over PN about VTO2000A with SIP and Asterisk, I think it is usefull to make this Thread. So everyone could ask here or post solutions for problems.

I have an VTO2000A and an VTH1550CH. But I want more flexibility.

What do I wanna have at end?
If someone rings the bell of VTO, I want ringing the VTH1550CH, ringing my FritzFon (over Fritzbox) and when I'm not at home, my Android-Smartphone should ringing to. And everything with Video. Well ringing with Videostream over Fritzbox will not work because the Fritzbox doesn't support SIP Video. But there is a possibility to use Snapshots instead.

My problems so far:
    - Main problem with SIP Firmware is that there will be no Push Notification on Dahua Android App gDMSS
    - When I use SIP Firmware with VTH1550 I only could use VTO as SIP Server to get connection between those two. But then my FritzFon will not ring.
    - When I use Asterisk as SIP Server my FritzFon are ringing but I get no Snapshot and I couldn't connect my VTH. I could insert the Dahua URL for Snapshots but this will not work with Fritzbox.
    - When I use Fritzbox as SIP Server, the FritzFon are ringing but when I pick up the FritzFon the VTO will end call after a few seconds because Fritzbox sends "183 Session Progress" as Answer and the VTO only accept "180 Ringing" as answer.

Solution for connection between Fritzbox and VTO.
If you wanna use Fritzbox with Telephone for ringing you have to use Asterisk as SIP Server and send an "180 Ringing" before Dial(). I will post my extensions.conf and sip.conf.

My Fritzbox will give "621" as number for Doorstation and callingnumber is 9901. So I gave the VTO as No. 8001 and 9901 as Villa Call Number. On Lan-Config / Server Type is Asterisk and Network Config / SIP Server Conifg is IP of Asterisk Username "8001" password you entered on extensions.conf and Realm is "asterisk". The VTO-No. must be something like 800x. I've added pictures of settings. I think this will be much easier to understand :)

Here my extensions.conf:
Code:
[general]
static=yes
writeprotect=no

[ausgehend]
exten => _9901,1,Set(CALLERID(num)=9901)
exten => _9901,n,Dial(Local/alle@tfe-zuhause,50,w)

[tfe-zuhause]
exten =>  alle,1,Ringing()
exten =>  alle,n,Dial(SIP/9901@videodoorgateway,50,w)

[default]
include => ausgehend
include


sip.conf:
Code:
[general]
language=de
bindport = 5060
bindaddr = 0.0.0.0
type=friend
context=eingehend
externrefresh=30
nat=force_rport,comedia
srvlookup=yes
transport=udp
localnet=192.168.1.xxx/255.255.255.0
;directmedia=no

[8001]
host=dynamic
username=VTO2000A
type=friend
secret=qwertz
context=ausgehend
disallow=all
allow=ulaw
allow=h264

[videodoorgateway]
context=eingehend
type=friend
insecure=invite
nat=force_rport,comedia instead
username=621
fromuser=621
fromdomain=fritz.box
secret=AnyPassword
host=192.168.1.xxx
dtmfmode=rfc2833
disallow=all
allow=ulaw
;allow=h264


I'm not very familiar with Asterisk, but with this settings connection between Fritzbox and VTO will work. What is missing is to create an URL with Snapshot when someone rings the bell.

Maybe someone has solutions and will post it here so everyone could pick up what he needs to get this real good hardware work well. Because Dahua will not give support. So we have to help ourselves.

If you post any solution, please write what system will work e.g. Android App or IPhone App with Asterisk (Videostream will work or not) and then what settings are needed to get it working.

I'm anxious to see your solutions or questions :)

EDIT:
Here screenshots of settings in VTO:
Image
Image
Image

That's all :)


Last edited by Allodo on Mon Oct 10, 2016 10:54 am, edited 2 times in total.

Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Sun Oct 09, 2016 2:54 pm 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Hi Allodo,

I also have a VTO2000A but my set up is a little different to yours, as I don't have a Fritzbox.

After a bit of digging around, I finally have my system working. My set up is as follows:

- Dahua VTO2000A as front door intercom at our home - used as SIP client
- Asterisk (FreePBX) running on Raspberry Pi - used as my server
- Mobile phones at home - used as SIP clients

To get the VTO2000A working as a SIP client, I needed to flash it with the SIP version of the firmware.

ftp://ftp.asm.cz/Dahua/videovratni/VTO2000A,VTO2000A-C/firmware/20160505-SIP.ZIP

In FreePBX, I created the following extensions for my various SIP clients at home:

- 8001 - used for the VTO2000A
- 8002 - used for mobile phone A
- 8003 - used for mobile phone B
- 8004 - used for laptop
- 5000 - used as a special number to handle Follow Me

As you can see, I created extension 5000 to support Follow Me, which is a module I installed within FreePBX. Among other things, it allows you create a 'ring group' so that the VTO2000A can call multiple extensions at the same time when the doorbell is pressed. I was originally using the Ring Group module, but that didn't work for me as the calls kept getting terminated after 5 seconds.

In terms of SIP client software on my devices, I tried both Zoiper and Bria on the iPhone and they both work OK.

On my laptop (Windows), I tried Linphone and Jitsi and both work fine.

From what I recall, in all of the SIP clients, I needed to install/enable/purchase support for H.264 since this is the video codec used by the VTO2000A.

Overall, I'm, happy with the system now. Whenever someone rings our front doorbell, all of our devices start ringing and the first one to answer establishes the video call with the person at the front door.

Cheers.


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Mon Oct 10, 2016 2:07 am 
Registered User

Joined: Jun 2016
Posts: 26

Offline
@pkozul
Quote:
As you can see, I created extension 5000 to support Follow Me, which is a module I installed within FreePBX.
Well sounds very interesting, and maybe one Point could be checked as feasible :)

Maybe you can show us your sip.conf and extensions.conf to see how you realized it. That would be great.
I've not installed FreePBX. So do I have to install something to use Follow Me, or is it normally included in Asterisk?


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Wed Oct 12, 2016 2:02 pm 
Registered User

Joined: Dec 2015
Posts: 23

Offline
As i am new to Dashua i just got it working as a Doorbell (audio only) using the VTO <-> Asterisk <-> Fritz!Box path.
Now i am starting to investigate video possibilities. Of course running Linphone as SIP client on Asterisk (without Fritz!Box) works, the VTO sends a videocall and i can see live video feed on my softphone.

With my old legacy doorbell i have it configured that whenever someone rings i get a Prowl Notification on my iPhone. When i'll put my VTO into production i want a message with a picture (Snapshot) on my iPhone. I don't know yet how i will transfer that picture. Maybe Whatsapp or Telegram.

I want to document here what i already found out concerning video.

- You have an RTSP stream listening on port 554. So by connecting to rtsp://admin:admin@192.168.xx.xx using a client like VideoLan (VLC) you can get the livestream (all the time, even when no-one rings).

- Knowing this i installed libav on my Debian 8 HomeAutomation box with
Code:
sudo apt install libav-tools

I was then able to create a snapshot by using the following command line:

Code:
avconv -i 'rtsp://admin:admin@192.168.xx.xx' -f image2 -vframes 1 -pix_fmt yuvj420p test.jpg


The IP address is of course the one of your VTO. So know i can create a snapshot whenever i want. Next step will be to choose a way to send that screenshot together with the notification to my iPhone. As far as i know Prowl can't send pictures. But this should probably be the easy part :-)

If someone knows more ways to access the video stream or to get a snapshot directly out of the VTO don't hesitate to complete...

Serge


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Wed Oct 12, 2016 3:01 pm 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Great info Serge. That is really useful.

On a separate note, I have found a way to unlock the front door during a video call with the VTO. For example, if I answer the call when someone rings from the VTO, during the call I can press a combination of keypad numbers in my app (DTMF), and that triggers a shell script on the Raspberry Pi which controls a relay to unlock the door. This means I am not even using of the VTO's built-in connections for unlocking the door (which I think requires a Dahua indoor station, or Dahua app). I haven't ordered a relay and door strike yet, but I have a few options in that area. I can either use a separate relay that I connect to the Raspberry Pi, or I can use one of the relays on my alarm panel. Either way, I can control these relays via the shell script that gets executed.

So, the way I got this working is by using 'dynamic features' within Asterisk, which allows you to use DTMF within your calls.

First, I defined a new dynamic feature called 'unlock-door'.

/etc/asterisk/globals_custom.conf

Code:
DYNAMIC_FEATURES = unlock-door

Then, I configured the 'unlock-door' dynamic feature to run the macro 'unlock-door' whenever DTMF code 777 is pressed.

/etc/asterisk/features_applicationmap_custom.conf

Code:
unlock-door => 777,self/callee,Macro,unlock-door

To ensure this 'unlock-door' dynamic feature is available in each call, I added it to 'the [from-internal]' context. As you can see within there, I also enabled extension *777 as an additional way to unlock the door (this is not via DTMF, but rather an extension that can be dialed at any time to unlock the door). Finally, I created the 'unlock-door' macro the does the actual work, that is, executes the shell script 'unlock-front-door.sh' (which controls the relay, and can do whatever else you want it to). You can see I used a condition in there, so that the shell script can only be executed by extensions other than the VTO2000A (which uses extension 8001).

/etc/asterisk/extensions_custom.conf

Code:
[from-internal]
exten => s,1,Set(__DYNAMIC_FEATURES=unlock-door)
exten => *777,1,Macro(macro-unlock-door,s,1)

[macro-unlock-door]
exten => s,1,ExecIf($["${CALLERID(num)}"!="8001"]?System(/var/lib/asterisk/agi-bin/unlock-front-door.sh))
exten => s,n,MacroExit

BTW, I have not made any changes to any other Asterisk config files. The above three files were all empty when I started, as they have been provided by FreePBX / Asterisk to allow you to add your own stuff.

As per my earlier post, I installed the Follow Me module within FreePBX to allow the VTO to call extension 5000, which is an extension I created to act as a ring group. For that extension,, I enabled Follow Me, and simply added all my other extension numbers to the ring group within the Follow Me tab for extension 5000.

I think I am very close to achieving what I wanted with the VTO200A.

The only thing left I can think of is finding a way to replace the voice/sound files on there, but I don't think anyone has been able to successfully replace these files and repack the firmware.

Also, has anyone been able to get the VTO to make ringing sounds when the button is pressed and it waits for someone to answer? I have tried a few things, but no luck. It would be good if the VTO could emit some rings or beeps while waiting for the other extensions to answer, rather than just a voice saying 'Calling..' (from what i remember) and then silence until someone answers, or until it times out. If all else fails, I will try to wire up a simple speaker (or cheap doorbell simply to make noise throughout the house) and see if I can get Asterisk to execute a shell script when the VTO initiates a call, in order to activate the speaker/doorbell. Not sure if that's possible with Asterisk, but worth investigating.


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Wed Oct 12, 2016 3:56 pm 
Registered User

Joined: Dec 2015
Posts: 23

Offline
Which Dashua app are you talking about ? If it can open the door it should be possible to tcpdump the traffic an simulate that request using a bash script (curl ?) called by asterisk.


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 10:04 am 
Registered User

Joined: Dec 2015
Posts: 23

Offline
pkozul wrote:
Also, has anyone been able to get the VTO to make ringing sounds when the button is pressed and it waits for someone to answer? I have tried a few things, but no luck. It would be good if the VTO could emit some rings or beeps while waiting for the other extensions to answer, rather than just a voice saying 'Calling..' (from what i remember) and then silence until someone answers, or until it times out. If all else fails, I will try to wire up a simple speaker (or cheap doorbell simply to make noise throughout the house) and see if I can get Asterisk to execute a shell script when the VTO initiates a call, in order to activate the speaker/doorbell. Not sure if that's possible with Asterisk, but worth investigating.


If i understand your request right it should not be difficult at all. I tested with the following dialplan:

Code:
exten=>9901,1,Ringing()
exten=>9901,n,Answer()
exten=>9901,n,Dial(SIP/linphone,30,m)
exten=>9901,n,Hangup()


And i have MusicOnHold playing on my VTO2000A while my linphone is ringing. The magic is done by the ",m" in the dial command.
Edit: if you use 'r' instead of 'm' you have a ringing tone instead MOH :-) I suppose this is exactly what you wanted ?

Code:
exten=>9901,n,Dial(SIP/linphone,30,r)


Does that answer your question ?

Serge


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 1:11 pm 
Registered User

Joined: Dec 2015
Posts: 23

Offline
I started analyzing the firmware to replace mp3 files. I think i am pretty close to be able to replace them.

The firmware file, for example General_VTO2000A_Eng_P_16M_SIP_V1.200.1000.0.R.20160505.bin, is a zip file of u-boot files in cramfs fs.
Code:
unzip General_VTO2000A_Eng_P_16M_SIP_V1.200.1000.0.R.20160505.bin

Archive:  General_VTO2000A_Eng_P_16M_SIP_V1.200.1000.0.R.20160505.bin
file #1:  bad zipfile offset (local header sig):  0
  inflating: dm365_ubl_boot_16M.bin.img 
  inflating: kernel-x.cramfs.img     
  inflating: romfs-x.cramfs.img     
  inflating: user-x.cramfs.img       
  inflating: web-x.cramfs.img       
  inflating: data-x.cramfs.img       
  inflating: pd-x.cramfs.img         
  inflating: custom-x.cramfs.img     
The sound files are in the data image file. u-boot uImage files have a header of 64 bytes, so you can mount the cramfs file simply by skipping the header:
Code:
mount -t cramfs -o loop,offset=64 data-x.cramfs.img /mnt
Code:
ls /mnt
Fonts  gbkpy.mb  Http  ProductInfo  Skins  Sounds  Strings
As soon as i have more time i will try to create a new data uImage with different mp3's for testing. I will just have to find out if the main zip file is a standard zip file or if it also has a special header, which is probably the case. In that case it will need some more investigation work to reproduce a working image ...

Everyone that has some it skills is invited to play around and share experiences :-)

Serge


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 3:42 pm 
Registered User

Joined: Sep 2016
Posts: 24

Offline
Hello!

Here are my first working settings from my Asterisk and VTO2000A and VTH1550. With help from Allodo.

sip.conf:
Code:
[general]
language=de
bindport = 5060
bindaddr = 0.0.0.0
;realm = meindyndnsname
;nat=yes
srvlookup=yes
;transport=udp
;localnet=192.168.178.40/255.255.255.0
directmedia=yes
videosupport=yes

[8001]
host=dynamic
username=VTO2000A   ;it is important that in VTO as RELAM are set asterisk!
type=friend
secret=admin
context=ausgehend
canreinvite=yes
qualify=yes
disallow=all
allow=ulaw
allow=h264

[8004]
videosupport=yes
type=friend
username=8004
secret=qwertz
context=ausgehend
dtmfmode=rfc2833
host=dynamic
canreinvite=yes
qualify=yes
nat=yes
allow=h264
allow=h263p
allow=h263

[9902]
type=friend
username=9902
secret=admin
context=ausgehend
dtmfmode=rfc2833
host=dynamic
canreinvite=yes
qualify=yes
allow=ulaw
allow=h264


And my extensions.conf:
Code:
[general]
static=yes
writeprotect=no

[ausgehend]
exten => _9901,1,Set(CALLERID(name)=VTO2000A)
exten => _9901,n,Dial(Local/alle@tfe-zuhause,50,w)
exten => _8001,1,Dial(SIP/8001,50,w)

[tfe-zuhause]
exten =>  alle,1,Ringing()
exten =>  alle,n,Dial(SIP/8004&SIP/9902,50,w)
;exten =>  alle,n,Dial(SIP/9901@videodoorgateway&SIP/8004&SIP/9902,50,w)

[default]
include => ausgehend


I have no Fritz-Fon, so i have not use the Part from Allodo for the fritz.box yet.

What works:
- Call with Audio and Video from VTO to VTH per Ring-Button. It works bevore accept the Call at the VTH and after that. Only for a short time the Video is gone, when the VTH switch from Monitoring to SIP-Video.
- Call from VTH to VTO as Monitor. Whena press the VTO Button on the VTH it connects and show the Video from outside. There are not red cross in the upper right corner. (it is important that set host=dynamic, at the VTH-Did)
- Call from VTH to VTO (call on the DID 8001 - SIP-Call) - Audio and Video works.
- Call from VTO to SIP-Clients - Bria, Zoiper, Voip by AntiSIP. Wit Audio and Video. But only with BRIA the Video is switsched autmotaicaly on. On the other clients i must set it manually. Not so good. I have not tested Linphone yet.
- Call from SIP-Client to VTO works in the same way, when i call the Number 8001.

It seems, that the Downloadrate from the Video (800x480) are about 2-2,3Mbps. This is for a usual DSL16 Internetconnection a little bit too much for the limited Upload rate of 1Mbps. ;-)
There is not known for me way to switch the Video for the SIP-Client from Channel 1 to 2 (lower resolution and frame rate). Only generaly the frame rate can be lowered, but this looks at the VTH indoor Station not good. ;-)

I hope it helps further. ;-)

Bye


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 4:13 pm 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Foxi352 wrote:
Which Dashua app are you talking about ? If it can open the door it should be possible to tcpdump the traffic an simulate that request using a bash script (curl ?) called by asterisk.

Hi Serge,

I don't own a VTH indoor monitor, but I can see in the manual (in section 2.2.) that it talks about remotely unlocking the door:

ftp://ftp.asm.cz/Dahua/kamerove_systemy/_User's_manual/07VDP/VTH/VTH1560B/VTH15%20Series%20User's%20Manual%20V3.2.0%20201405.pdf

As you said, it would be great if someone could capture the traffic to see what is actually being sent by the VTH indoor monitor to unlock the door. Anyone here able to do that?

I believe there are some mobile apps (iDMSS and gDMSS) from Dahua, but not sure if they can be used to unlock the door.


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 4:17 pm 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Foxi352 wrote:
I started analyzing the firmware to replace mp3 files. I think i am pretty close to be able to replace them.

Great work Serge.

Not sure if you have come across this before, but another guy has done some work around unpacking / repacking firmware images for Dahua IP cameras.

https://github.com/BotoX/Dahua-Firmware-Mod-Kit

Maybe there is some helpful stuff in that project?


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 4:28 pm 
Registered User

Joined: Dec 2015
Posts: 23

Offline
pkozul wrote:
Maybe there is some helpful stuff in that project?


There is a lot of helpful stuff in there, thanks a lot !


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Thu Oct 13, 2016 4:49 pm 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Foxi352 wrote:
pkozul wrote:
Maybe there is some helpful stuff in that project?


There is a lot of helpful stuff in there, thanks a lot !

The author of that project just said he is actively working on it and will hopefully have support for CramFS in the next few days.


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Fri Oct 14, 2016 6:17 am 
Registered User

Joined: Dec 2015
Posts: 23

Offline
I had a bit of spare time this morning and contributed a PR to the project that:
- adds support for multiple config files
- includes a VTO2000A sample config file
- adds cramfs support for extract.py

As soon as i have a bit more time i will work on cramfs support for build.py and then try to build a modified FW for our VTO's ...

Meanwhile if someone wants to test to extract the FW and familiarise yourself with the file system structure you can pull my work here:

https://github.com/Foxi352/Dahua-Firmware-Mod-Kit.git

Don't forget to switch to the vto2000a branch.

Serge


Top
 Profile  
Reply with quote  

  
 Post subject: Re: Dahua VTO2000A, SIP Firmware and Asterisk
PostPosted: Fri Oct 14, 2016 6:49 am 
Registered User

Joined: Oct 2016
Posts: 17

Offline
Hi Serge,

Just getting back to you regarding your suggestion about how to get the VTO to play music or make ringing sounds while waiting for it to establish a call.

I tried your suggestion but couldn't get it working. I think it's because I'm using Follow Me to manage the ring group I have set up, and that has it's own dial plans, macros, etc.

In any case, I finally got it working. I simply added the following macro, which is a 'hook' that allows you to inject your own code as the ring group is being called.

/etc/asterisk/extensions_custom.conf

Code:
[macro-dial-ringall-predial-hook]
exten => s,n,Ringing()
exten => s,n,Answer

I believe this is only really relevant for those using FreeBPX and the Follow Me module to handle ring groups.

We're getting there slowly... keep up the great work!


Top
 Profile  
Reply with quote  

Display posts from previous:  Sort by  
Reply to topic  [ 117 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next


Who is online

Users browsing this forum: Google [Bot], jeromephone and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

It is currently Fri Nov 24, 2017 3:24 pm

The contents of this webpage are copyright © 2003-2016 CCTVForum.com. All Rights Reserved.