Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion detection not being advertised? #19

Open
tERB00 opened this issue Nov 22, 2024 · 49 comments
Open

Motion detection not being advertised? #19

tERB00 opened this issue Nov 22, 2024 · 49 comments

Comments

@tERB00
Copy link

tERB00 commented Nov 22, 2024

Hello! I have an issue where both Synology and a hardware NVR can not seem to detect the motion detection capability of a camera running onvif_simple_server. On Syno there is no option to choose to have motion detected "by camera" (only disabled or by synology) and NVR board I have just have grayed out all the motion detection options for the camera. Am I missing something in the config file (I hope) or is it a bug?

# General
model=vanhua_z55i
manufacturer=thingino
firmware_ver=newest
hardware_id=ingenic
serial_num=yay
ifs=eth0
port=80
scope=onvif://www.onvif.org/Profile/Streaming
scope=onvif://www.onvif.org/Profile/T
scope=onvif://www.onvif.org/hardware
scope=onvif://www.onvif.org/name
user=thingino
password=thingino

#Advanced options
adv_enable_media2=1
adv_fault_if_unknown=0
adv_fault_if_set=0
adv_synology_nvr=1

#Profile 0
name=Profile_0
width=2560
height=1440
url=rtsp://%s/ch0
snapurl=http://%s/image.jpg
type=H265
audio_decoder=AAC
audio_encoder=NONE

#Profile 1
name=Profile_1
width=640
height=360
url=rtsp://%s/ch1
snapurl=http://%s/onvif/image.cgi?width=640&height=360
type=H265
audio_decoder=AAC
audio_encoder=NONE

#PTZ
ptz=0
max_step_x=0
max_step_y=0
get_position=motors -p
move_left=motors -d h -x 0
move_right=motors -d h -x 
move_up=motors -d h -y 0
move_down=motors -d h -y 
move_stop=motors -d s
move_preset=/sbin/ptz_presets %d
goto_home_position=motors -d b
get_presets=/sbin/ptz_presets -g
jump_to_abs=motors -d h -x %f -y %f
jump_to_rel=motors -d g -x %f -y %f

#EVENT
events=1
#Event 0
topic=tns1:VideoSource/MotionAlarm
source_name=VideoSourceConfigurationToken
source_value=VideoSourceToken
input_file=/run/motion/motion_alarm

P.S. Notify server works fine and detects motions well it seems:

2024-11-22 14:45:09 DEBUG conf.c:122: events: 1
2024-11-22 14:45:09 DEBUG conf.c:122: topic: tns1:VideoSource/MotionAlarm
2024-11-22 14:45:09 DEBUG conf.c:122: source_name: VideoSourceConfigurationToken
2024-11-22 14:45:09 DEBUG conf.c:122: source_value: VideoSourceToken
2024-11-22 14:45:09 DEBUG conf.c:122: input_file: /run/motion/motion_alarm
2024-11-22 14:45:09 INFO  onvif_notify_server.c:628: Completed.
2024-11-22 14:45:09 DEBUG utils.c:111: Created shared memory object /onvif_subscription
2024-11-22 14:45:09 DEBUG utils.c:128: Shared memory segment allocated correctly (2368 bytes) at address 0x77eea000
2024-11-22 14:45:09 DEBUG onvif_notify_server.c:682: 0: /run/motion/motion_alarm
2024-11-22 14:45:09 INFO  onvif_notify_server.c:725: Listening for events.
2024-11-22 14:45:57 DEBUG onvif_notify_server.c:420: File /run/motion/motion_alarm created
2024-11-22 14:45:57 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 14:45:58 DEBUG onvif_notify_server.c:423: File /run/motion/motion_alarm deleted
2024-11-22 14:45:58 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 14:46:03 DEBUG onvif_notify_server.c:420: File /run/motion/motion_alarm created
2024-11-22 14:46:03 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 14:46:06 DEBUG onvif_notify_server.c:423: File /run/motion/motion_alarm deleted
2024-11-22 14:46:06 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 14:50:22 DEBUG onvif_notify_server.c:420: File /run/motion/motion_alarm created
2024-11-22 14:50:22 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 14:50:24 DEBUG onvif_notify_server.c:423: File /run/motion/motion_alarm deleted
2024-11-22 14:50:24 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 15:05:01 DEBUG onvif_notify_server.c:420: File /run/motion/motion_alarm created
2024-11-22 15:05:01 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
2024-11-22 15:05:02 DEBUG onvif_notify_server.c:423: File /run/motion/motion_alarm deleted
2024-11-22 15:05:02 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file
@roleoroleo
Copy link
Owner

You should check if your client supports PullPoint or Base Subscription.
events=1 means PullPoint.
If you are not sure about this, set events to 3 and onvif_simple_server will publish both methods.

@tERB00
Copy link
Author

tERB00 commented Nov 25, 2024

Yeah events=3 was a default setting - I changed it to 1 to see if it can fix my issue. It does not work either way.

@roleoroleo
Copy link
Owner

Please check if it works with another client, for example Onvif Device Manager.

@tERB00
Copy link
Author

tERB00 commented Nov 27, 2024

I would love to check and compare with a known good working camera but I am not familiar with onvif's data structure. I don't know where to look and what to look for. If you can give me some instructions it would be much appreciated.

@roleoroleo
Copy link
Owner

Download Onvif Device Manager (it's a Windows software), install and run it.
If wsd_simple_server is running it should detect your cam automatically.
When you select the cam, ODM will open a connection for events.
You can configure in the options, PullPoint or WS-Base.
https://sourceforge.net/projects/onvifdm/

@tERB00
Copy link
Author

tERB00 commented Nov 27, 2024

Well, the page is just empty - there is no records, no errors, no nothing.
A working camera looks like this:
image

@tERB00
Copy link
Author

tERB00 commented Nov 28, 2024

I've been walking in front of a camera back and forth to trigger the motion and finally saw ONE message appeared on the Events tab! It was "Motion End" event. With no "Motion Start" before it.

I checked onvif_notify_server debug log (see my 1st post) and it is detecting motion start event flag file no problem.

The message was there on this page and few minutes later It has disappeared. While other cameras display a message history for past few hours.

So my guess there is a problem between onvif_notify_server and onvif_simple_server where the event messages not being conveyed properly or reliably or something like that.

@roleoroleo
Copy link
Owner

roleoroleo commented Nov 30, 2024

It's strange, because onvif_notify_server is logging the subscription:

2024-11-22 14:45:57 DEBUG onvif_notify_server.c:420: File /run/motion/motion_alarm created
2024-11-22 14:45:57 DEBUG onvif_notify_server.c:452: 1 notification subscriptions for /run/motion/motion_alarm file

This log means that onvif_notify_server knows that there is 1 subscription.
Maybe the firewall? If you are using WS-Base, the connection starts from the cam and the firewall must be configured to accept this connection type.
In my case, I have to disable Windows Defender when I test events with ODM.

@tERB00
Copy link
Author

tERB00 commented Nov 30, 2024

Well, SOME messages are coming through so it's not that. It cant be selective isn't it?
And it does not work with Synology and a hardware NVR - these 2 do not have any firewalls for sure.

@roleoroleo
Copy link
Owner

I don't understand.
Are you able to capture the network traffic between the cam and the onvif client?
You should:
1 - run onvif_notify_server with verbose debug (-d 5)
2 - start the network capture
3 - open ODM and connect to the cam
4 - share with me the log, the capture file and a ODM screenshot

@tERB00
Copy link
Author

tERB00 commented Dec 14, 2024

image

Here are required files. Please remove ".log" from the pcap file. I had to add that so github let me upload it.

@roleoroleo
Copy link
Owner

Please, pull the repo.
I think I found the bug.

@tERB00
Copy link
Author

tERB00 commented Dec 14, 2024

Well yeah - that's a progress! I can see motion event start and end in ODM now!
But neither Synology or hardware NVR still does not recognize camera's motion detection capability. And I still think it is something to do with advertisement or handshake. The software probably does not report that it has this option.
Here I captured a connection and event from another camera that works well with both Syno and NVR, Maybe you can take a look and spot a difference?

@roleoroleo
Copy link
Owner

Could you send me the same capture for the non working cam?

@tERB00
Copy link
Author

tERB00 commented Dec 15, 2024

Sure thing! Here is how it looks after the patch:
image

@roleoroleo
Copy link
Owner

The logs are different but I can't understand what's the problem.
But I installed a testing environment with DSM and Surveillance Station.
Please, describe me how you install a new cam and test the events support in DSM.

@tERB00
Copy link
Author

tERB00 commented Dec 22, 2024

Yeah so in short you got to
"IP Camera" => Add
It discovers your cameras, you tick the box, click next
It asks you for username and pass
You select Basic Setup or Advanced Setup it does not matter
You click save and the camera is added and starts continuous recording

Then you got to the camera list, select your camera, click edit and go to the Event Detection menu.
In the drop down menu there is no "By Camera" detection source to select:
image

Should be like this:
image

@roleoroleo
Copy link
Owner

Ok. I'll try.

@roleoroleo
Copy link
Owner

Nothing.
4 hours spent trying to figure out why it doesn't work.
I can't understand where is the difference between the two threads: the working cam and the non working cam.

@tERB00
Copy link
Author

tERB00 commented Dec 23, 2024

Well, thanks for trying anyways! At least you fixed subscription expire bug

@tERB00 tERB00 closed this as completed Dec 23, 2024
@roleoroleo
Copy link
Owner

roleoroleo commented Dec 23, 2024

I will try again when I come back home

@roleoroleo roleoroleo reopened this Dec 23, 2024
@roleoroleo
Copy link
Owner

Are you sure that your cam is not using a native protocol to send detection messages?
If I'm not wrong SS supports many proprietary protocols from different manufacturers.

@tERB00
Copy link
Author

tERB00 commented Dec 24, 2024

Yes, I'm sure it's onvif.
image
Two way audio works too via onvif. This camera is really compatible.

@WMP
Copy link

WMP commented Dec 31, 2024

I have this same, i use YI cam with your firmware version 0.3.9 with enabled Synology compatiblity. This is few onvif tcpdumps from my synology:

POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 922


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
	xmlns:s="http://www.w3.org/2003/05/soap-envelope">
	<s:Header>
		<wsse:Security
			xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
			xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken>
				<wsse:Username>root</wsse:Username>
				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">CUT</wsse:Password>
				<wsse:Nonce>CUT</wsse:Nonce>
				<wsu:Created>2024-12-31T22:46:33Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</s:Header>
	<s:Body
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<CreateProfile
			xmlns="http://www.onvif.org/ver10/media/wsdl">
			<Name>SynoProfile</Name>
		</CreateProfile>
	</s:Body>
</s:Envelope>HTTP/1.1 500 Internal Server Error
Content-type: application/soap+xml
Content-Length: 1472


<SOAP-ENV:Envelope
	xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
	xmlns:wsa5="http://www.w3.org/2005/08/addressing"
	xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
	xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
	xmlns:ter="http://www.onvif.org/ver10/error">
	<SOAP-ENV:Header>
		<wsa5:MessageID>"urn:uuid:067342ac-43ff-4ecd-462b-227a424bdf0d"</wsa5:MessageID>
		<wsa5:ReplyTo SOAP-ENV:mustUnderstand="true">
			<wsa5:Address>http://192.168.123.27/onvif</wsa5:Address>
		</wsa5:ReplyTo>
		<wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.123.27/onvif/media_service</wsa5:To>
		<wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.w3.org/2005/08/addressing/soap/fault"</wsa5:Action>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body>
		<SOAP-ENV:Fault>
			<SOAP-ENV:Code>
				<SOAP-ENV:Value>SOAP-ENV:Receiver</SOAP-ENV:Value>
				<SOAP-ENV:Subcode>
					<SOAP-ENV:Value>ter:Action</SOAP-ENV:Value>
					<SOAP-ENV:Subcode>
						<SOAP-ENV:Value>ter:MaxNVTProfiles</SOAP-ENV:Value>
					</SOAP-ENV:Subcode>
				</SOAP-ENV:Subcode>
			</SOAP-ENV:Code>
			<SOAP-ENV:Reason>
				<SOAP-ENV:Text xml:lang="en">Max profile number reached</SOAP-ENV:Text>
			</SOAP-ENV:Reason>
			<SOAP-ENV:Node>http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver</SOAP-ENV:Node>
			<SOAP-ENV:Role>http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver</SOAP-ENV:Role>
			<SOAP-ENV:Detail>
				<SOAP-ENV:Text>The maximum number of supported profiles supported by the device has been reached</SOAP-ENV:Text>
			</SOAP-ENV:Detail>
		</SOAP-ENV:Fault>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 899


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
	xmlns:s="http://www.w3.org/2003/05/soap-envelope">
	<s:Header>
		<wsse:Security
			xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
			xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken>
				<wsse:Username>root</wsse:Username>
				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">CUT</wsse:Password>
				<wsse:Nonce>CUT</wsse:Nonce>
				<wsu:Created>2024-12-31T22:46:33Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</s:Header>
	<s:Body
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<GetVideoSourceConfigurations
			xmlns="http://www.onvif.org/ver10/media/wsdl" />
		</s:Body>
	</s:Envelope>HTTP/1.1 200 OK
Content-type: application/soap+xml
Content-Length: 1551


	<?xml version="1.0" encoding="UTF-8"?>
	<SOAP-ENV:Envelope
		xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
		xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex"
		xmlns:wsa5="http://www.w3.org/2005/08/addressing"
		xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
		xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
		xmlns:xmime="http://tempuri.org/xmime.xsd"
		xmlns:xop="http://www.w3.org/2004/08/xop/include"
		xmlns:tt="http://www.onvif.org/ver10/schema"
		xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
		xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
		xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
		xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
		xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
		xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
		xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
		xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
		xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
		<SOAP-ENV:Body>
			<trt:GetVideoSourceConfigurationsResponse>
				<trt:Configurations token="VideoSourceConfigToken">
					<tt:Name>VideoSourceConfig</tt:Name>
					<tt:UseCount>1</tt:UseCount>
					<tt:SourceToken>VideoSourceToken</tt:SourceToken>
					<tt:Bounds x="0" y="0" width="1920" height="1080"/>
				</trt:Configurations>
			</trt:GetVideoSourceConfigurationsResponse>
		</SOAP-ENV:Body>
	</SOAP-ENV:Envelope>

POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 940


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
	xmlns:s="http://www.w3.org/2003/05/soap-envelope">
	<s:Header>
		<wsse:Security
			xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
			xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken>
				<wsse:Username>root</wsse:Username>
				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">CUT</wsse:Password>
				<wsse:Nonce>CUT</wsse:Nonce>
				<wsu:Created>2024-12-31T22:46:34Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</s:Header>
	<s:Body
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<GetVideoSourceConfigurationOptions
			xmlns="http://www.onvif.org/ver10/media/wsdl">
		</GetVideoSourceConfigurationOptions>
	</s:Body>
</s:Envelope>HTTP/1.1 200 OK
Content-type: application/soap+xml
Content-Length: 1732


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
	xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
	xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex"
	xmlns:wsa5="http://www.w3.org/2005/08/addressing"
	xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
	xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
	xmlns:xmime="http://tempuri.org/xmime.xsd"
	xmlns:xop="http://www.w3.org/2004/08/xop/include"
	xmlns:tt="http://www.onvif.org/ver10/schema"
	xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
	xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
	xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
	xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
	xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
	xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
	xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
	xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
	xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
	<SOAP-ENV:Body>
		<trt:GetVideoSourceConfigurationOptionsResponse>
			<trt:Options>
				<tt:BoundsRange>
					<tt:XRange>
						<tt:Min>0</tt:Min>
						<tt:Max>1920</tt:Max>
					</tt:XRange>
					<tt:YRange>
						<tt:Min>0</tt:Min>
						<tt:Max>1080</tt:Max>
					</tt:YRange>
					<tt:WidthRange>
						<tt:Min>0</tt:Min>
						<tt:Max>1920</tt:Max>
					</tt:WidthRange>
					<tt:HeightRange>
						<tt:Min>0</tt:Min>
						<tt:Max>1080</tt:Max>
					</tt:HeightRange>
				</tt:BoundsRange>
				<tt:VideoSourceTokensAvailable>VideoSourceToken</tt:VideoSourceTokensAvailable>
			</trt:Options>
		</trt:GetVideoSourceConfigurationOptionsResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

POST /onvif/device_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 939


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
	xmlns:s="http://www.w3.org/2003/05/soap-envelope">
	<s:Header>
		<wsse:Security
			xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
			xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken>
				<wsse:Username>root</wsse:Username>
				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">CUT</wsse:Password>
				<wsse:Nonce>CUT</wsse:Nonce>
				<wsu:Created>2024-12-31T22:46:33Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</s:Header>
	<s:Body
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<GetServices
			xmlns="http://www.onvif.org/ver10/device/wsdl">
			<IncludeCapability>false</IncludeCapability>
		</GetServices>
	</s:Body>
</s:Envelope>HTTP/1.1 200 OK
Content-type: application/soap+xml
Content-Length: 1979


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
	xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
	xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex"
	xmlns:wsa5="http://www.w3.org/2005/08/addressing"
	xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
	xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
	xmlns:xmime="http://tempuri.org/xmime.xsd"
	xmlns:xop="http://www.w3.org/2004/08/xop/include"
	xmlns:tt="http://www.onvif.org/ver10/schema"
	xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
	xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
	xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
	xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
	xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
	xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
	xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
	xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
	xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
	<SOAP-ENV:Body>
		<tds:GetServicesResponse>
			<tds:Service>
				<tds:Namespace>http://www.onvif.org/ver10/device/wsdl</tds:Namespace>
				<tds:XAddr>http://192.168.123.27/onvif/device_service</tds:XAddr>
				<tds:Version>
					<tt:Major>19</tt:Major>
					<tt:Minor>12</tt:Minor>
				</tds:Version>
			</tds:Service>
			<tds:Service>
				<tds:Namespace>http://www.onvif.org/ver10/events/wsdl</tds:Namespace>
				<tds:XAddr>http://192.168.123.27/onvif/events_service</tds:XAddr>
				<tds:Version>
					<tt:Major>18</tt:Major>
					<tt:Minor>6</tt:Minor>
				</tds:Version>
			</tds:Service>
			<tds:Service>
				<tds:Namespace>http://www.onvif.org/ver10/media/wsdl</tds:Namespace>
				<tds:XAddr>http://192.168.123.27/onvif/media_service</tds:XAddr>
				<tds:Version>
					<tt:Major>19</tt:Major>
					<tt:Minor>6</tt:Minor>
				</tds:Version>
			</tds:Service>
		</tds:GetServicesResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

@roleoroleo
Copy link
Owner

Try to remove the line
<tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
fromGetEventProperties_2.xml

@WMP
Copy link

WMP commented Jan 2, 2025 via email

@roleoroleo
Copy link
Owner

Yes, you can edit the file with vi through a ssh session.
About the problem, try to clean the cache of the browser.

@tERB00
Copy link
Author

tERB00 commented Jan 2, 2025

Try to remove the line
<tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
fromGetEventProperties_2.xml

Nothing changed on my end...

@roleoroleo
Copy link
Owner

Yes, it's not enough but I found the problem (I think).
In the configuration file set
source_name=Source

@WMP
Copy link

WMP commented Jan 2, 2025

Yes, after:

sed -i  /tmp/onvif_simple_server.conf -e 's/source_name=VideoSourceConfigurationToken/source_name=Source/g'
kill 2077
onvif_notify_server --conf_file /tmp/onvif_simple_server.conf

In tcpdump i see:

POST /onvif/events_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 890


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
        xmlns:s="http://www.w3.org/2003/05/soap-envelope">
        <s:Header>
                <wsse:Security
                        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                        <wsse:UsernameToken>
                                <wsse:Username>root</wsse:Username>
                                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">...</wsse:Password>
                                <wsse:Nonce>...</wsse:Nonce>
                                <wsu:Created>2025-01-02T22:21:59Z</wsu:Created>
                        </wsse:UsernameToken>
                </wsse:Security>
        </s:Header>
        <s:Body
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <GetEventProperties
                        xmlns="http://www.onvif.org/ver10/events/wsdl" />
                </s:Body>
        </s:Envelope>HTTP/1.1 200 OK
Content-type: application/soap+xml
Content-Length: 3810


        <?xml version="1.0" encoding="UTF-8"?>
        <SOAP-ENV:Envelope
                xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:wsa5="http://www.w3.org/2005/08/addressing"
                xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
                xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
                xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
                xmlns:tns1="http://www.onvif.org/ver10/topics"
                xmlns:tt="http://www.onvif.org/ver10/schema">
                <SOAP-ENV:Header>
                        <wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.onvif.org/ver10/events/wsdl/EventPortType/GetEventPropertiesResponse</wsa5:Action>
                </SOAP-ENV:Header>
                <SOAP-ENV:Body>
                        <tev:GetEventPropertiesResponse>
                                <tev:TopicNamespaceLocation>http://www.onvif.org/onvif/ver10/topics/topicns.xml</tev:TopicNamespaceLocation>
                                <wsnt:FixedTopicSet>true</wsnt:FixedTopicSet>
                                <wstop:TopicSet>
                                        <tns1:VideoSource>
                                                <MotionAlarm  wstop:topic="true">
                                                        <tt:MessageDescription IsProperty="true">
                                                                <tt:Source>
                                                                        <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                        <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                </tt:Source>
                                                                <tt:Data>
                                                                        <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                </tt:Data>
                                                        </tt:MessageDescription>
                                                </MotionAlarm>
                                        </tns1:VideoSource>
                                        <tns1:RuleEngine>
                                                <MyRuleDetector>
                                                        <PeopleDetect  wstop:topic="true">
                                                                <tt:MessageDescription IsProperty="true">
                                                                        <tt:Source>
                                                                                <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                                <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                        </tt:Source>
                                                                        <tt:Data>
                                                                                <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                        </tt:Data>
                                                                </tt:MessageDescription>
                                                        </PeopleDetect>
                                                </MyRuleDetector>
                                        </tns1:RuleEngine>
                                        <tns1:RuleEngine>
                                                <MyRuleDetector>
                                                        <VehicleDetect  wstop:topic="true">
                                                                <tt:MessageDescription IsProperty="true">
                                                                        <tt:Source>
                                                                                <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                                <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                        </tt:Source>
                                                                        <tt:Data>
                                                                                <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                        </tt:Data>
                                                                </tt:MessageDescription>
                                                        </VehicleDetect>
                                                </MyRuleDetector>
                                        </tns1:RuleEngine>
                                        <tns1:RuleEngine>
                                                <MyRuleDetector>
                                                        <DogCatDetect  wstop:topic="true">
                                                                <tt:MessageDescription IsProperty="true">
                                                                        <tt:Source>
                                                                                <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                                <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                        </tt:Source>
                                                                        <tt:Data>
                                                                                <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                        </tt:Data>
                                                                </tt:MessageDescription>
                                                        </DogCatDetect>
                                                </MyRuleDetector>
                                        </tns1:RuleEngine>
                                        <tns1:RuleEngine>
                                                <MyRuleDetector>
                                                        <BabyCryingDetect  wstop:topic="true">
                                                                <tt:MessageDescription IsProperty="true">
                                                                        <tt:Source>
                                                                                <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                                <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                        </tt:Source>
                                                                        <tt:Data>
                                                                                <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                        </tt:Data>
                                                                </tt:MessageDescription>
                                                        </BabyCryingDetect>
                                                </MyRuleDetector>
                                        </tns1:RuleEngine>
                                        <tns1:AudioAnalytics>
                                                <Audio>
                                                        <DetectedSound  wstop:topic="true">
                                                                <tt:MessageDescription IsProperty="true">
                                                                        <tt:Source>
                                                                                <tt:SimpleItemDescription Name="Source" Type="tt:ReferenceToken"/>
                                                                                <tt:SimpleItemDescription Name="Rule" Type="xsd:string"/>
                                                                        </tt:Source>
                                                                        <tt:Data>
                                                                                <tt:SimpleItemDescription Name="State" Type="xsd:boolean"/>
                                                                        </tt:Data>
                                                                </tt:MessageDescription>
                                                        </DetectedSound>
                                                </Audio>
                                        </tns1:AudioAnalytics>
                                </wstop:TopicSet>
                                <wsnt:TopicExpressionDialect>http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet</wsnt:TopicExpressionDialect>
                                <wsnt:TopicExpressionDialect>http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete</wsnt:TopicExpressionDialect>
                                <tev:MessageContentFilterDialect>http://www.onvif.org/ver10/tev/messageContentFilter/ItemFilter</tev:MessageContentFilterDialect>
                                <tev:MessageContentSchemaLocation>http://www.onvif.org/onvif/ver10/schema/onvif.xsd</tev:MessageContentSchemaLocation>
                        </tev:GetEventPropertiesResponse>
                </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>

and i also see (this POST if without response):

==> 12.xml <==
POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 922


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
        xmlns:s="http://www.w3.org/2003/05/soap-envelope">
        <s:Header>
                <wsse:Security
                        xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                        <wsse:UsernameToken>
                                <wsse:Username>root</wsse:Username>
                                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">...</wsse:Password>
                                <wsse:Nonce>...</wsse:Nonce>
                                <wsu:Created>2025-01-02T22:21:58Z</wsu:Created>
                        </wsse:UsernameToken>
                </wsse:Security>
        </s:Header>
        <s:Body
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <CreateProfile
                        xmlns="http://www.onvif.org/ver10/media/wsdl">
                        <Name>SynoProfile</Name>
                </CreateProfile>
        </s:Body>
</s:Envelope>
==> 13.xml <==
POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Accept: */*
Content-Type: application/xml; charset=UTF-8
Content-Length: 335


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
        xmlns:s="http://www.w3.org/2003/05/soap-envelope">
        <s:Body
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <CreateProfile
                        xmlns="http://www.onvif.org/ver10/media/wsdl">
                        <Name>SynoProfile</Name>
                </CreateProfile>
        </s:Body>
</s:Envelope>

But in Synology i have only this option:
image

For reolink camera i have option: "By camera"

@roleoroleo
Copy link
Owner

Check my last commits.
immagine
immagine

@WMP
Copy link

WMP commented Jan 3, 2025

What is most simple method to build onvif simple server form main and put this to YiCam?

@tERB00
Copy link
Author

tERB00 commented Jan 3, 2025

After changing source_name=Source in the config Synology does recognize camera's motion detection and it works now.
Hardware NVR however still does not work but I'll wait for camera's firmware to recompile and see if other commits will make any difference.

@roleoroleo
Copy link
Owner

What is most simple method to build onvif simple server form main and put this to YiCam?

If you mean Allwinner-v2:

  • clone the repo (Allwinner-v2, not onvif_simple_server)
  • go to src/onvif_simple_server folder
  • run init.onvif_simple_server
  • run compile.onvif_simple_server
  • copy the content of _install folder to /tmp/sd/yi-hack overwriting all old files
  • if the files are busy, kill all onvif processes and try again to copy

@roleoroleo
Copy link
Owner

After changing source_name=Source in the config Synology does recognize camera's motion detection and it works now.
Hardware NVR however still does not work but I'll wait for camera's firmware to recompile and see if other commits will make any difference.

What's the problem, onvif in general or events handling?

@WMP
Copy link

WMP commented Jan 3, 2025

What is most simple method to build onvif simple server form main and put this to YiCam?

I means v1:

majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif$ git clone https://github.com/roleoroleo/yi-hack-Allwinner.git
Cloning into 'yi-hack-Allwinner'...
remote: Enumerating objects: 6492, done.
remote: Counting objects: 100% (2187/2187), done.
remote: Compressing objects: 100% (836/836), done.
remote: Total 6492 (delta 1431), reused 1967 (delta 1238), pack-reused 4305 (from 1)
Receiving objects: 100% (6492/6492), 3.39 MiB | 7.37 MiB/s, done.
Resolving deltas: 100% (4252/4252), done.
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif$ cd yi-hack-Allwinner/
assets/  .git/    .github/ scripts/ sdhack/  src/     sysroot/ unbrick/ 
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif$ cd yi-hack-Allwinner/src/onvif_simple_server/
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master =)$ ls
cleanup.onvif_simple_server  compile.onvif_simple_server  init.onvif_simple_server  install.onvif_simple_server  mbedtls_config.h  onvif_simple_server  path.patch
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master =)$ ls onvif_simple_server/
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master =)$ vim init.onvif_simple_server 
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master *=)$ git diff init.onvif_simple_server
diff --git a/src/onvif_simple_server/init.onvif_simple_server b/src/onvif_simple_server/init.onvif_simple_server
index 08b3bcb..da7ff01 100755
--- a/src/onvif_simple_server/init.onvif_simple_server
+++ b/src/onvif_simple_server/init.onvif_simple_server
@@ -8,7 +8,7 @@ rm -rf ./_install
 if [ ! -f crypt-1.18.2.tar.xz ]; then
     wget https://github.com/libtom/libtomcrypt/releases/download/v1.18.2/crypt-1.18.2.tar.xz
 fi
-tar Jxvf ./crypt-1.18.2.tar.xz
+tar Jxf ./crypt-1.18.2.tar.xz
 if [ ! -L libtomcrypt ]; then
     ln -s libtomcrypt-1.18.2 libtomcrypt
     cd onvif_simple_server/extras
@@ -19,7 +19,7 @@ fi
 if [ ! -f v3.4.0.tar.gz ]; then
     wget https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.4.0.tar.gz
 fi
-tar zxvf ./v3.4.0.tar.gz
+tar zxf ./v3.4.0.tar.gz
 if [ ! -L mbedtls ]; then
     ln -s mbedtls-3.4.0 mbedtls
     cd onvif_simple_server/extras
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master *=)$ ./init.onvif_simple_server 
./init.onvif_simple_server: line 4: cd: too many arguments
--2025-01-03 15:28:44--  https://github.com/libtom/libtomcrypt/releases/download/v1.18.2/crypt-1.18.2.tar.xz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/777011/8715752c-7e4f-11e8-8ae5-ea70868d9221?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250103T142844Z&X-Amz-Expires=300&X-Amz-Signature=cf6fa6bc4080cb24a3881c97392b6e8225bc61c409ed678a9cd84a37093853c5&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcrypt-1.18.2.tar.xz&response-content-type=application%2Foctet-stream [following]
--2025-01-03 15:28:44--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/777011/8715752c-7e4f-11e8-8ae5-ea70868d9221?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250103T142844Z&X-Amz-Expires=300&X-Amz-Signature=cf6fa6bc4080cb24a3881c97392b6e8225bc61c409ed678a9cd84a37093853c5&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dcrypt-1.18.2.tar.xz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.109.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2638064 (2,5M) [application/octet-stream]
Saving to: ‘crypt-1.18.2.tar.xz’

crypt-1.18.2.tar.xz                                          100%[============================================================================================================================================>]   2,52M  1,89MB/s    in 1,3s    

2025-01-03 15:28:46 (1,89 MB/s) - ‘crypt-1.18.2.tar.xz’ saved [2638064/2638064]

./init.onvif_simple_server: line 14: cd: onvif_simple_server/extras: No such file or directory
--2025-01-03 15:28:46--  https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.4.0.tar.gz
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/Mbed-TLS/mbedtls/tar.gz/refs/tags/v3.4.0 [following]
--2025-01-03 15:28:47--  https://codeload.github.com/Mbed-TLS/mbedtls/tar.gz/refs/tags/v3.4.0
Resolving codeload.github.com (codeload.github.com)... 140.82.121.9
Connecting to codeload.github.com (codeload.github.com)|140.82.121.9|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v3.4.0.tar.gz’

v3.4.0.tar.gz                                                    [      <=>                                                                                                                                    ]   4,67M  3,87MB/s    in 1,2s    

2025-01-03 15:28:48 (3,87 MB/s) - ‘v3.4.0.tar.gz’ saved [4892512]

./init.onvif_simple_server: line 25: cd: onvif_simple_server/extras: No such file or directory
cp: cannot stat 'mbedtls_config.h': No such file or directory
./init.onvif_simple_server: line 31: cd: onvif_simple_server: No such file or directory
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
./init.onvif_simple_server: line 35: ../path.patch: No such file or directory
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master *%=)$ 

@roleoroleo
Copy link
Owner

There are submodules.
After cloning you need to update submodules:
git submodule update --init

@WMP
Copy link

WMP commented Jan 3, 2025

So:

majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master *=)$ grep tt:Quality onvif_simple_server/media_service_files/GetProfile_VEC.xml 
                    <tt:Quality>100</tt:Quality>
majanows@EliteBook-840-G9:~/Praca/Moje glpupoty/kamera-salon-onvif/yi-hack-Allwinner/src/onvif_simple_server (master *=)$ ls

./init.onvif_simple_server #in this file i need to get SCRIPT_DIR in "" because i have space in path
export STAGING_DIR=ddd #because arm-openwrt-linux-muslgnueabi-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
./compile.onvif_simple_server
cd _install/
scp -O -r * [email protected]:/home/yi-hack/

and on camera:

root@kamera-salon:/tmp# cat /tmp/onvif_simple_server.conf
model=Yi Hack
manufacturer=Yi
firmware_ver=0.3.9
hardware_id=9FUS
serial_num=9FUSY31K7C2FO3200319
ifs=wlan0
port=80
scope=onvif://www.onvif.org/Profile/Streaming
adv_fault_if_unknown=0
adv_synology_nvr=1

#Profile 0
name=Profile_0
width=1920
height=1080
url=rtsp://%s/ch0_0.h264
snapurl=http://%s/cgi-bin/snapshot.sh?res=high&watermark=yes
type=H264
decoder=NONE

#EVENT
events=3
#Event 0
topic=tns1:VideoSource/MotionAlarm
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/motion_alarm
#Event 1
topic=tns1:RuleEngine/MyRuleDetector/PeopleDetect
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/human_detection
#Event 2
topic=tns1:RuleEngine/MyRuleDetector/VehicleDetect
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/vehicle_detection
#Event 3
topic=tns1:RuleEngine/MyRuleDetector/DogCatDetect
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/animal_detection
#Event 4
topic=tns1:RuleEngine/MyRuleDetector/BabyCryingDetect
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/baby_crying
#Event 5
topic=tns1:AudioAnalytics/Audio/DetectedSound
source_name=Source
source_value=VideoSourceToken
input_file=/tmp/onvif_notify_server/sound_detection
root@kamera-salon:/tmp# killall wsd_simple_server onvif_notify_server
root@kamera-salon:/tmp# onvif_notify_server --conf_file /tmp/onvif_simple_server.conf
root@kamera-salon:/tmp# wsd_simple_server --pid_file /var/run/wsd_simple_server.pid --if_name wlan0 --xaddr http://%s/onvif/device_service -m kamera-salon -n Yi
root@kamera-salon:/tmp# ps | grep onvif
28664 root       796 S    onvif_notify_server --conf_file /tmp/onvif_simple_server.conf
28690 root       688 S    wsd_simple_server --pid_file /var/run/wsd_simple_server.pid --if_name wlan0 --xaddr http://%s/onvif/device_service -m kamera-salon -n Yi
28743 root       980 S    grep onvif
root@kamera-salon:/tmp#

But in synology i have error about cannot found stream address, i havent copied this message.

In tcpdump:

POST /onvif/media_service HTTP/1.1
Host: 192.168.123.27
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 922


<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
	xmlns:s="http://www.w3.org/2003/05/soap-envelope">
	<s:Header>
		<wsse:Security
			xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
			xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
			<wsse:UsernameToken>
				<wsse:Username>root</wsse:Username>
				<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">...</wsse:Password>
				<wsse:Nonce>...</wsse:Nonce>
				<wsu:Created>2025-01-03T21:04:22Z</wsu:Created>
			</wsse:UsernameToken>
		</wsse:Security>
	</s:Header>
	<s:Body
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<CreateProfile
			xmlns="http://www.onvif.org/ver10/media/wsdl">
			<Name>SynoProfile</Name>
		</CreateProfile>
	</s:Body>
</s:Envelope>HTTP/1.1 500 Internal Server Error
Content-type: application/soap+xml
Content-Length: 1471


<SOAP-ENV:Envelope
	xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
	xmlns:wsa5="http://www.w3.org/2005/08/addressing"
	xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
	xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
	xmlns:ter="http://www.onvif.org/ver10/error">
	<SOAP-ENV:Header>
		<wsa5:MessageID>"urn:uuid:067342ac-43ff-4ecd-462b-227a424bdf0d"</wsa5:MessageID>
		<wsa5:ReplyTo SOAP-ENV:mustUnderstand="true">
			<wsa5:Address>http://192.168.123.27/onvif</wsa5:Address>
		</wsa5:ReplyTo>
		<wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.123.27/onvif/media_service</wsa5:To>
		<wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.w3.org/2005/08/addressing/soap/fault</wsa5:Action>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body>
		<SOAP-ENV:Fault>
			<SOAP-ENV:Code>
				<SOAP-ENV:Value>SOAP-ENV:Receiver</SOAP-ENV:Value>
				<SOAP-ENV:Subcode>
					<SOAP-ENV:Value>ter:Action</SOAP-ENV:Value>
					<SOAP-ENV:Subcode>
						<SOAP-ENV:Value>ter:MaxNVTProfiles</SOAP-ENV:Value>
					</SOAP-ENV:Subcode>
				</SOAP-ENV:Subcode>
			</SOAP-ENV:Code>
			<SOAP-ENV:Reason>
				<SOAP-ENV:Text xml:lang="en">Max profile number reached</SOAP-ENV:Text>
			</SOAP-ENV:Reason>
			<SOAP-ENV:Node>http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver</SOAP-ENV:Node>
			<SOAP-ENV:Role>http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver</SOAP-ENV:Role>
			<SOAP-ENV:Detail>
				<SOAP-ENV:Text>The maximum number of supported profiles supported by the device has been reached</SOAP-ENV:Text>
			</SOAP-ENV:Detail>
		</SOAP-ENV:Fault>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Maybe i have problem with build this?

@roleoroleo
Copy link
Owner

This message is normal.
Synology tries to create a new onvif media profile (just as a test, even if it's useless), but onvif_simple_server is a read-only server.
The maximum number of possible profiles is 2 and CreateProfile fails.
But it's not a problem, Synology should continue the negotiation.
If you use the last commit, config file must be updated with source_type line.

@WMP
Copy link

WMP commented Jan 4, 2025

I'm not sure if this is working as expected... Yesterday, my camera restarted. Today, I ran killall onvif_notify_server wsd_simple_server again, then transferred the build files from yesterday using scp, replaced the events section in the camera configuration with the example from this repository, restarted the killed services, started tcpdump, and attempted to add the camera to Synology. However, in the summary, I still see the following (as usual):

Screenshot_20250104_192624

Next i see error:
Screenshot_20250104_192758

Additionally, in the configuration, I couldn't select "by camera":
Screenshot_20250104_192928

There is pcap file and ONVIF dump:
192.168.123.27.not-work.pcap.zip
onvif-not-work.txt

I suspect that this binary might have some verbose output or logs available, so I tried running it with debug mode enabled. Here’s what I did:

root@kamera-salon:~# killall onvif_notify_server
root@kamera-salon:~# onvif_notify_server --conf_file /tmp/onvif_simple_server.conf -d 5 -f
Don't daemonize
19:10:30 INFO  onvif_notify_server.c:621: Starting program.
19:10:30 DEBUG onvif_notify_server.c:623: pid_file = /var/run/onvif_notify_server.pid
19:10:30 INFO  onvif_notify_server.c:638: Processing configuration file /tmp/onvif_simple_server.conf...
19:10:30 DEBUG conf.c:128: model: Yi Hack
19:10:30 DEBUG conf.c:128: manufacturer: Yi
19:10:31 DEBUG conf.c:128: firmware_ver: 0.3.9
19:10:31 DEBUG conf.c:128: hardware_id: 9FUS
19:10:31 DEBUG conf.c:128: serial_num: 9FUSY31K7C2FO3200319
19:10:31 DEBUG conf.c:128: ifs: wlan0
19:10:31 DEBUG conf.c:128: port: 80
19:10:31 DEBUG conf.c:128: scope: onvif://www.onvif.org/Profile/Streaming
19:10:31 DEBUG conf.c:128: adv_fault_if_unknown: 0
19:10:31 DEBUG conf.c:128: adv_synology_nvr: 1
19:10:31 DEBUG conf.c:128: name: Profile_0
19:10:31 DEBUG conf.c:128: width: 1920
19:10:31 DEBUG conf.c:128: height: 1080
19:10:31 DEBUG conf.c:128: url: rtsp://%s/ch0_0.h264
19:10:31 DEBUG conf.c:128: snapurl: http://%s/cgi-bin/snapshot.sh?res=high&watermark=yes
19:10:31 DEBUG conf.c:128: type: H264
19:10:31 DEBUG conf.c:128: decoder: NONE
19:10:31 WARN  conf.c:537: Unrecognized option: decoder=NONE
19:10:31 DEBUG conf.c:128: events: 3
19:10:31 DEBUG conf.c:128: topic: tns1:VideoSource/MotionAlarm
19:10:31 DEBUG conf.c:128: source_name: Source
19:10:31 DEBUG conf.c:128: source_type: tt:ReferenceToken
19:10:31 DEBUG conf.c:128: source_value: VideoSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/motion_alarm
19:10:31 DEBUG conf.c:128: topic: tns1:RuleEngine/MyRuleDetector/PeopleDetect
19:10:31 DEBUG conf.c:128: source_name: VideoSourceConfigurationToken
19:10:31 DEBUG conf.c:128: source_type: xsd:string
19:10:31 DEBUG conf.c:128: source_value: VideoSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/human_detection
19:10:31 DEBUG conf.c:128: topic: tns1:RuleEngine/MyRuleDetector/VehicleDetect
19:10:31 DEBUG conf.c:128: source_name: VideoSourceConfigurationToken
19:10:31 DEBUG conf.c:128: source_type: xsd:string
19:10:31 DEBUG conf.c:128: source_value: VideoSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/vehicle_detection
19:10:31 DEBUG conf.c:128: topic: tns1:RuleEngine/MyRuleDetector/DogCatDetect
19:10:31 DEBUG conf.c:128: source_name: VideoSourceConfigurationToken
19:10:31 DEBUG conf.c:128: source_type: xsd:string
19:10:31 DEBUG conf.c:128: source_value: VideoSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/animal_detection
19:10:31 DEBUG conf.c:128: topic: tns1:RuleEngine/MyRuleDetector/BabyCryingDetect
19:10:31 DEBUG conf.c:128: source_name: AudioSourceConfigurationToken
19:10:31 DEBUG conf.c:128: source_type: xsd:string
19:10:31 DEBUG conf.c:128: source_value: AudioSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/baby_crying
19:10:31 DEBUG conf.c:128: topic: tns1:AudioAnalytics/Audio/DetectedSound
19:10:31 DEBUG conf.c:128: source_name: AudioSourceConfigurationToken
19:10:31 DEBUG conf.c:128: source_type: tt:ReferenceToken
19:10:31 DEBUG conf.c:128: source_value: AudioSourceToken
19:10:31 DEBUG conf.c:128: input_file: /tmp/onvif_notify_server/sound_detection
19:10:31 INFO  onvif_notify_server.c:651: Completed.
19:10:31 DEBUG utils.c:117: Created shared memory object /onvif_subscription
19:10:31 DEBUG utils.c:134: Shared memory segment allocated correctly (2272 bytes) at address 0xb6ffa000
19:10:31 DEBUG onvif_notify_server.c:705: 0: /tmp/onvif_notify_server/motion_alarm
19:10:31 DEBUG onvif_notify_server.c:705: 1: /tmp/onvif_notify_server/human_detection
19:10:31 DEBUG onvif_notify_server.c:705: 2: /tmp/onvif_notify_server/vehicle_detection
19:10:31 DEBUG onvif_notify_server.c:705: 3: /tmp/onvif_notify_server/animal_detection
19:10:31 DEBUG onvif_notify_server.c:705: 4: /tmp/onvif_notify_server/baby_crying
19:10:31 DEBUG onvif_notify_server.c:705: 5: /tmp/onvif_notify_server/sound_detection
19:10:31 ERROR onvif_notify_server.c:712: inotify interface not implemented, try poll strategy
19:10:31 INFO  onvif_notify_server.c:748: Listening for events.
19:10:31 INFO  onvif_notify_server.c:775: File /tmp/onvif_notify_server/human_detection created
19:10:31 DEBUG onvif_notify_server.c:795: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
19:10:46 INFO  onvif_notify_server.c:800: File /tmp/onvif_notify_server/human_detection deleted
19:10:46 DEBUG onvif_notify_server.c:820: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
19:10:53 INFO  onvif_notify_server.c:775: File /tmp/onvif_notify_server/human_detection created
19:10:53 DEBUG onvif_notify_server.c:795: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file


ADD CAMERA HERE


19:11:53 INFO  onvif_notify_server.c:800: File /tmp/onvif_notify_server/human_detection deleted
19:11:53 DEBUG onvif_notify_server.c:820: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
19:12:17 INFO  onvif_notify_server.c:775: File /tmp/onvif_notify_server/human_detection created
19:12:17 DEBUG onvif_notify_server.c:795: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
19:13:19 INFO  onvif_notify_server.c:800: File /tmp/onvif_notify_server/human_detection deleted
19:13:19 DEBUG onvif_notify_server.c:820: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
19:13:20 INFO  onvif_notify_server.c:775: File /tmp/onvif_notify_server/human_detection created
19:13:20 DEBUG onvif_notify_server.c:795: 0 notification subscriptions for /tmp/onvif_notify_server/human_detection file
^C19:13:40 INFO  onvif_notify_server.c:828: Listening for events stopped.
19:13:40 DEBUG utils.c:163: Shared memory segment deallocated correctly
19:13:40 INFO  onvif_notify_server.c:837: Terminating program.
root@kamera-salon:~# 

An unrecognized option warning appeared for decoder=NONE.

After running the camera in foreground mode, Synology still couldn't authenticate with the camera. I suspect there might be a threading issue in this mode. Therefore, I stopped it and restarted the camera without foreground mode:

root@kamera-salon:~# onvif_notify_server --conf_file /tmp/onvif_simple_server.conf -d 5
root@kamera-salon:~# tail -F /tmp/onvif_simple_server.*log
==> /tmp/onvif_simple_server.log <==




I then started tcpdump (after entering the IP in Synology, so this tcpdump missed the first two ONVIF messages) and repeated the process of deleting and adding the camera. This time, the camera was added successfully, and motion detection worked. Here are the pcap file and ONVIF dump for the successful attempt:

onvif.working.txt
192.168.123.27.working.pcap.zip

However, I later noticed that Synology still didn’t detect the motion event.

Here’s what happened:

At 19:53 local time (20:53), the camera detected motion, and the file human_detection was created in /tmp/onvif_notify_server:

root@kamera-salon:/tmp/onvif_notify_server# ls -latr
-rw-rw-rw-    1 root     root             0 Jan  4 19:53 human_detection
drwxr-xr-x    2 root     root            60 Jan  4 19:53 .
drwxrwxrwt    9 root     root           720 Jan  4 19:53 ..
root@kamera-salon:/tmp/onvif_notify_server#

Despite this, Synology didn’t register any motion event:
image

Below is the ONVIF dump captured during the time of motion detection:
onvif-human-detection.txt

@roleoroleo
Copy link
Owner

roleoroleo commented Jan 5, 2025

I think it's better if I prepare a new image for you, before restarting with the test.
What's your model suffix?

@WMP
Copy link

WMP commented Jan 5, 2025

Firmware Version 0.3.9
Base Version 8.2.0.0A_201912270941
Model Suffix y20ga

@roleoroleo
Copy link
Owner

Here it is:
y20ga_0.3.9.tgz

@WMP
Copy link

WMP commented Jan 5, 2025

Ok, now i added without any problems, but issue is still with sending notifiction about human detection to synology - i dont see motion event in synology.

root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            40 Jan  5 20:01 .
drwxrwxrwt    9 root     root           740 Jan  5 20:01 ..
root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            60 Jan  5 20:01 .
drwxrwxrwt    9 root     root           760 Jan  5 20:01 ..
-rw-rw-rw-    1 root     root             0 Jan  5 20:01 human_detection
root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            60 Jan  5 20:01 .
drwxrwxrwt    9 root     root           760 Jan  5 20:01 ..
-rw-rw-rw-    1 root     root             0 Jan  5 20:01 human_detection
root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            60 Jan  5 20:03 .
drwxrwxrwt    9 root     root           760 Jan  5 20:03 ..
-rw-rw-rw-    1 root     root             0 Jan  5 20:03 human_detection
root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            60 Jan  5 20:03 .
drwxrwxrwt    9 root     root           740 Jan  5 20:04 ..
-rw-rw-rw-    1 root     root             0 Jan  5 20:03 human_detection
root@kamera-salon:/tmp/onvif_notify_server# ls -la 
drwxr-xr-x    2 root     root            40 Jan  5 20:04 .
drwxrwxrwt    9 root     root           740 Jan  5 20:04 ..
root@kamera-salon:/tmp/onvif_notify_server#

xml dump:
human-detection-202501052105.dump.txt

@roleoroleo
Copy link
Owner

roleoroleo commented Jan 5, 2025 via email

@WMP
Copy link

WMP commented Jan 5, 2025

I see that human_detection was only when my wife has moved, when she stop human_detection has gone.

@roleoroleo
Copy link
Owner

What I mean to say is that Synology, afaik, is able to handle just "motion detection" events (tns1:VideoSource/MotionAlarm).
Other messages like "audio detection", "human detection" or other rule based messages are not handled.
If you want to detect human, you should change onvif_simple_server.conf (change the origin file).

@WMP
Copy link

WMP commented Jan 7, 2025

Ok, I thought to find a way for synology to support more events than just motion_detection. A quick google prompted me that some synology profiles support various onvif events. I accessed the synology configuration files, and wrote a piece of script that found me profiles that have these settings:

api=onvif h264=rtsp rtsp_protocol=tcp media_entry=/onvif/media onvif_*_topic

I tested on the profile for the LTS VSIP8442W-28MA camera, and synology reads the image and can save.

Unfortunately events it can not recognize because this profile has such onvif_topic:

onvif_md_topic = tns1:VideoSource/MotionAlarm;Source*ReferenceToken;State*boolean 

which is completely different from what YiHack sends. I have attached an imperfectly processed configuration of profiles that meet the above settings (chatGPT some more and more lazy...), could you tell which profile would be the best to adapt for YiHack?

profile.test.txt

Obviously YiHack's synology compatibility option would have to expose events on the paths that the profile expects.

@roleoroleo
Copy link
Owner

This topic:
tns1:VideoSource/MotionAlarm
is exactly what Yi hack uses for standard motion detection.
But if you want to use other detections, you will find the topics in the config file:

topic=tns1:RuleEngine/MyRuleDetector/PeopleDetect
topic=tns1:RuleEngine/MyRuleDetector/VehicleDetect
topic=tns1:RuleEngine/MyRuleDetector/DogCatDetect
topic=tns1:RuleEngine/MyRuleDetector/BabyCryingDetect
topic=tns1:AudioAnalytics/Audio/DetectedSound

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants