On 15 Jul 2011 at 8:26, Fulko Hew wrote:
> On Fri, Jul 15, 2011 at 3:10 AM, Giuseppe Modugno
> <[email protected]> wrote:
> > In this case, when the amplifier is muted, there's no idea
> > about the last gain level to restore when the switch is open
> > again turning the encoder right.
>
> Doesn't this imply that the variable(s) are/should-be 'read-only' for
> this current hw?
The rotary encoder was just an example of the behaviour of the
hardware I'm using. There isn't really any encoder, push-buttons or
similar. I have only a software API (I can't touch) with some
functions to control the status and settings of the box. I'd like
to convert these functions to SNMP.
Two of these functions are:
int volume_set(int volume);
int volume_get(void);
where volume could be -1 to mute the amplifier or a number between 0
and 1000 at 5 steps. If a bad value is passed to the function (for
example, -2 or 33), the function does nothing and returns with an
error.
> > I think the approach with two OIDs can be adapted to an
> > amplifier with a rotary encoder for the gain level control
> > and a *separate* switch for the mute.
>
> If you think about it... it could apply to both hardware
> implementations.
If I decide to implement two SNMP variables, one for mute and one
for volume level, how should I use volume_set() function?
When the user wants to mute the amplifier, he sends a SET request of
the "mute variable" and the agent converts this request to:
volume_set(-1);
Now the user wants to read the volume level and sends a GET request
of the "volume variable". The agent converts the request to
volume_get();
but -1 is returned, because the amplifier is really muted and the
API don't remember the last volume level.
The only possibility I see to implement two SNMP variables in the
agent is to store the last volume level inside the agent before
muting the amplifier:
old_volume = volume_get();
volume_set(-1);
So when the amplifier is unmuted I can do:
volume_set(old_volume);
But this means I have to save this data in a non-volatile way,
because the amplifier could be switched off in any moment without
any advice.
What do you think? Are my thoughts correct?
------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
