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

Send command "how-to" #440

Closed
ghost opened this issue Dec 31, 2015 · 21 comments
Closed

Send command "how-to" #440

ghost opened this issue Dec 31, 2015 · 21 comments

Comments

@ghost
Copy link

ghost commented Dec 31, 2015

Hello,

Traccar3.2 but last traccar-web.war (12-23)

I want to send cut OFF/ON engine, I don't know where/howto parameter SMS function please ?

Thanks.

@vitalidze
Copy link
Owner

I think you should either use the Engine Stop/Engine Resume commands, if they are supported by your device and implemented in traccar backend (this should be reported when you try to send the command). Another option is to try with Custom command. You should read documentation about your device on which commands you can send and their format.

@ghost
Copy link
Author

ghost commented Dec 31, 2015

What I don't understand is : how traccar knows howto send the command ? Usualy whith my own phone, I send sms command to the device. If I write the #stop#passwd# this command must go out my server; how does it do that ? Do I need a center sms server ?

@vitalidze
Copy link
Owner

It sends commands over the internet channel, which is opened when your device connects to the traccar server. Again, your device must support this way of communication. Maybe your particular device can support SMS commands only. To figure that out you should either read documentation about your device.

@khfrabbi
Copy link

khfrabbi commented Jan 3, 2016

I am getting below message after sending any command to "Meitrack T1"
Please guide

Traccar 3.3
Traccar-web 0.10.2

{"reason":"java.lang.ClassNotFoundException: org.traccar.model.Factory","success":false}

@vitalidze
Copy link
Owner

It is not supported with traccar 3.3 for now. Use 3.2 instead

воскресенье, 3 января 2016 г. пользователь khfrabbi написал:

I am getting below message after sending any command to "Meitrack T1"
Please guide

Traccar 3.3
Traccar-web 0.10.2

{"reason":"java.lang.ClassNotFoundException:
org.traccar.model.Factory","success":false}


Reply to this email directly or view it on GitHub
#440 (comment)
.

Kind regards, Vitaly Litvak

@khfrabbi
Copy link

khfrabbi commented Jan 4, 2016

As per your suggestion I did, now it shows another message

{"reason":"The device is not registered on the server","success":false}

What can I do to register my device on the server?

Meitrack T1 Device
Traccar 3.2
Traccar-web 0.10.2

@vitalidze
Copy link
Owner

This means that at the moment you were trying to send command your device wasn't connected to the server.

@khfrabbi
Copy link

I don't know what mistake I did.

Please suggest what can I do now

NB : Commands using SMS working fine on my Meitrack T1 Device

@vitalidze
Copy link
Owner

@khfrabbi most probably it was sent if you don't see an error message. Are you sure that particular command is supported by traccar and your device?

Have you tried sending same command from the original UI? If it does not work from there then it's better to ask same question here

@hanselsen
Copy link

@vitalidze I have the same issue like stated here earlier.
{"reason":"java.lang.ClassNotFoundException: org.traccar.model.Factory","success":false}
We really would like to keep using 3.3. When do you think is this resolved?
Thanks!

@vitalidze
Copy link
Owner

@hanselsen I don't have any estimated date. It will be resolved when I find some free time to install version 3.3 and update instructions.

@hanselsen
Copy link

Allright thanks for the quick reply. I will be patient then. Good luck.

@hanselsen
Copy link

@vitalidze On https://github.com/vitalidze/traccar-web/blob/dev/src/main/java/org/traccar/web/server/model/DataServiceImpl.java#L1020 there is the error. But I see that local variable isn't used afterwards. Maybe a solution to just throw away line 1020?

@vitalidze
Copy link
Owner

@hanselsen It is used on the next line.

@hanselsen
Copy link

Oh stupid. I search for it using CTRL+F but there was a whitespace after it, so it wasn't found. Haha excuse me

@hanselsen
Copy link

@vitalidze I've created, from what I think, a workaround (or solution). Would you care to take a look at my approach?
DataServiceImpl.zip

@vitalidze
Copy link
Owner

@hanselsen so your only change is that you have removed this line

Class<?> backendFactoryClass = Class.forName("org.traccar.model.Factory");

And changed this one:

Method objectFromJson = backendJsonConverterClass.getDeclaredMethod("objectFromJson", Reader.class, Class.class);

Right?

It looks correct for version 3.3, but it won't work for version 3.2 and 3.1. I cannot do it this way because I want compatibility for all versions of traccar that support sending of commands. Anyway, thank you for the suggestion.

My solution would be to surround Class.forName for the '...Factory' argument with try..catch and in catch block just use your solution. Something like this:

// ...
Method objectFromJson;
try {
    Class<?> backendFactoryClass = Class.forName("org.traccar.model.Factory");
    objectFromJson = backendJsonConverterClass.getDeclaredMethod("objectFromJson", Reader.class, backendFactoryClass);
} catch (ClassNotFoundException e) {
    objectFromJson = backendJsonConverterClass.getDeclaredMethod("objectFromJson", Reader.class, Class.class);
}
// ...

@hanselsen
Copy link

Yes, but I also enhanced the Catch clause, so that if the Command is not supported, not a crash will display, but it's showing that it's not supported.

Anyhow, for the backwards compatibility, I think you're definitely on the right track. Although I'm not very fond of try and catch for implementing behaviour, but I googled a bit and it seems you're solution is the way to go.

@ahmedtab
Copy link

Hello
I would be glad if you can figure this out please. When I send any command the respond is
{"reason":"java.lang.reflect.InvocationTargetException: null","success":false}
Using Traccar 3.2,Traccar-web 0.10.3, device is EV601.
I tryed it on my server and within your demo server and the result is always same.
I think my device is not supporting sending commands in tracker-server , yet what about a Custom type?. Are there any modifications? must I do it in tracker-server or in traccar-web.
Thanks

@vitalidze
Copy link
Owner

@ahmedtab to figure out the reason of what's happening please provide contents of wrapper.log file right after you reproduce the issue. It should contain a stack trace of the error. If your device does not support commands yet, then it's better to ask on the backend issue tracker: https://github.com/tananaev/traccar/issues

As for the "Custom type" it may work if your command is a text command and you set it in a proper format. I would play with custom commands in your case.

vitalidze added a commit that referenced this issue Feb 9, 2016
@vitalidze
Copy link
Owner

Fixed, written news, updated latest and demo versions.

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

No branches or pull requests

4 participants