Device-Ericsson-AccessoryMenu

 view release on metacpan or  search on metacpan

lib/Device/Ericsson/AccessoryMenu.pm  view on Meta::CPAN

=cut

sub send_text {
    my $self = shift;
    my $title = shift;
    @_ = ($title) unless @_;

    $self->enter_state( 'Text', title => $title, lines => \@_ );
}


=head2 percent_slider( %args )

 %args = (
    title    => 'Slider',
    steps    => 10,    # 1..10
    value    => 50,
    callback => undef, # a subroutine ref, will be called with the new value
 );

=cut

sub percent_slider {
    my $self = shift;
    my %args = @_;

    my $value = defined $args{value} ? $args{value}: 50;
    $self->enter_state( 'Slider', ( title => $args{title} || 'Slider',
                                    steps => $args{steps}  || 10,
                                    value => $value,
                                    callback => $args{callback} ) );
}

=head2 mouse_mode( %args )

Put the T68i into a fullscan mode.  Returns keyboard events for every
key pressed and released.

 %args = (
    title    => 'Mouse',
    callback => sub ( $key, $updown ) {}, # will be called with the key and
                                          # the updown event (1 = key
                                          # down, 0 = key up)

 );

=cut

sub mouse_mode {
    my $self = shift;
    my %args = @_;

    $self->enter_state( 'Mouse', ( title => $args{title} || 'Mouse',
                                   callback => $args{callback} ) );
}


=head2 control

Respond to what the phone is sending back over the port, invoking
callbacks and all that jazz.

=cut

sub control {
    my $self = shift;
    my ($timeout) = @_;

    # $self->port->modemlines; may be the key to 'it's attached, it's
    # not attached' stuff

    my $line = $self->expect("\r", $timeout);
    return unless $line;

    print "# control '$line'\n" if $self->debug;

    if ( my $state = $self->current_state ) {
        $state->handle( $line );
        return;
    }

    if ($line =~ /EAAI/) { # top level menu
        $self->enter_state( 'Menu', data => $self->menu );
        return;
    }

    warn "control got unexpected '$line'\n";
}

1;
__END__

=head1 CAVEATS

I have only tested this with a T68i, and with Device::SerialPort.
I've consulted the R320 command set, and this seems portable across
Ericsson devices, but only time will tell.  Feedback welcome.

=head1 TODO

Convenience methods for other C<EAID> values, like the percent input
dialog.

Disconnection (and reconnection) detection.  For a straight serial
port this isn't really much of a win, but for bluetooth devices it'd
be nifty to do a "they've entered/exited the zone" check.

=head1 AUTHOR

Richard Clamp <richardc@unixbeard.net>

Based on the source of bluexmms by Tom Gilbert.

=head1 COPYRIGHT

Copyright (C) 2003, Richard Clamp.  All Rights Reserved.

This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO



( run in 1.101 second using v1.01-cache-2.11-cpan-140bd7fdf52 )