Michael,
I think there is a confusion around the use
of vehicle_fn_smshandler - that is to override (premsg) or
extend (!premsg) an existing SMS command. I hadn't thought about
the vehicle module wanting its own SMS messages.
We can do this in two ways: (1) expose a vehicle sms handler
table to the net_sms code and have it look there, or (2) just
hook in to the vehicle and let it handle sms messages itself.
For the moment, I've chosen (2) as I think there will be
relatively few vehicle-specific sms messages. The old way we did
this was just 'strcmp' for each possible SMS commands. If there
are not too many, that is fine and probably more efficient than
having a dispatch table. Anyway, I've added
a vehicle_fn_smsextensions now, which is called if the incoming
sms is not recognised by net_sms and allows the vehicle to look.
Michael B: can you try to migrate your Twizy code to this
new vehicle_fn_smsextensions framework for Twizy-specific sms
messages, and vehicle_fn_smshandler for the extension to the
STAT command? Regarding your vehicle_twizy_sms_handle_stat()
function, is it not possible to just extend (add a couple of
lines) the SMS reply, rather than replace the entire command?
I also tested the new net_sms arrangement, found a few bugs,
and fixed them. Code is on github now.
I'm now looking at implementing a registration mechanism so
that the vehicle modules can register the commands they
implement, as well as other parameters for what they support,
and we can push this in net_msg when we connect to the server.
Regards, Mark.
Mark,
I ported my STAT changes to the new framework and tried to
prepare it for my first specific commands as well:
https://github.com/dexterbg/Open-Vehicle-Monitoring-System/commit/7b050c4dd92045d62bce3315122ac496c5d305c6
Haven't tested yet, but the vehicle / framework
distinction becomes very clean now I think.
Regarding hooking in the vehicle cmdtable: I now think
that was nonsense, as the vehicle dispatcher will need to
parse the command itself. I'll wait for your thoughts on
if/how to integrate the common auth stuff with this.
To get internal net_sms_stat() calls to use the overloaded
function, I suggest to inject the call through the SMS
dispatcher as shown in my commit. There's only one call
outside net_sms, and that's not time critical and using
fixed (no) arguments. I also think STAT is the only SMS we
need to route like this (?)
Regards,
Michael