<commit_before>/*
 * Copyright (C) 2011 Klaus 'mrmoku' Kurzmann
 * Copyright (C) 2011 Michael 'Mickey' Lauer <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

using GLib;
using Gee;
using FsoGsm;

/**
 * @class Gtm601.Modem
 *
 * This modem plugin supports standard AT modems that do not use a multiplexing mode.
 *
 **/
class Gtm601.Modem : FsoGsm.AbstractModem
{
    private const string CHANNEL_NAME = "main";

    public override string repr()
    {
        return "<>";
    }

    public override void configureData()
    {
        assert( modem_data != null );

        modem_data.simHasReadySignal = true; // $QCSIMSTAT
        modem_data.simReadyTimeout = 5; /* seconds */

        theModem.atCommandSequence( "MODEM", "init" ).append( {
            "$QCSIMSTAT=1"          /* enable sim status report */
        } );

        registerAtCommandSequence( "main", "init", new AtCommandSequence( {
            """+CGEREP=2,1""",
            """+CGREG=2""",
            """+CLIP=1""",
            """+CREG=2""",
            """+COLP=0""",
            """+CSSN=1,1""",
            """+CTZU=1""",
            """+CTZR=1"""
        } ) );

        var cnmiCommand = modem_data.simBuffersSms ? """+CNMI=2,1,2,1,1""" : """+CNMI=2,2,2,1,1""";

        // sequence for when the modem is registered
        registerAtCommandSequence( "main", "registered", new AtCommandSequence( {
            cnmiCommand,
            """+CSMS=1""" /* enable SMS phase 2 */
        } ) );

        registerAtCommandSequence( "main", "suspend", new AtCommandSequence( {
            """+CSQI=0""" /* disable signal strength updates */
        } ) );

        registerAtCommandSequence( "main", "resume", new AtCommandSequence( {
            """+CSQI=1""" /* enable signal strength updates */
        } ) );
    }

    protected override void createChannels()
    {
        var transport = FsoFramework.Transport.create( modem_transport, modem_port, modem_speed );
        var parser = new FsoGsm.StateBasedAtParser();
        new AtChannel( CHANNEL_NAME, transport, parser );
    }

    protected override FsoGsm.Channel channelForCommand( FsoGsm.AtCommand command, string query )
    {
        // nothing to round-robin here as gmt601 only has one channel
        return channels[ CHANNEL_NAME ];
    }

    protected override void registerCustomMediators( HashMap<Type,Type> mediators )
    {
        Gtm601.registerCustomMediators( mediators );
    }

    protected override FsoGsm.UnsolicitedResponseHandler createUnsolicitedHandler()
    {
        return new Gtm601.UnsolicitedResponseHandler();
    }

    protected override void registerCustomAtCommands( HashMap<string,FsoGsm.AtCommand> commands )
    {

        var plusCops = theModem.createAtCommand<PlusCOPS>( "+COPS" );
        PlusCOPS.providerNameDeliveredInConfiguredCharset = true;<commit_msg>fsogsmd: modem_option_gtm601: fix signal strength command<commit_after>/*
 * Copyright (C) 2011 Klaus 'mrmoku' Kurzmann
 * Copyright (C) 2011 Michael 'Mickey' Lauer <ml<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 */

using GLib;
using Gee;
using FsoGsm;

/**
 * @class Gtm601.Modem
 *
 * This modem plugin supports standard AT modems that do not use a multiplexing mode.
 *
 **/
class Gtm601.Modem : FsoGsm.AbstractModem
{
    private const string CHANNEL_NAME = "main";

    public override string repr()
    {
        return "<>";
    }

    public override void configureData()
    {
        assert( modem_data != null );

        modem_data.simHasReadySignal = true; // $QCSIMSTAT
        modem_data.simReadyTimeout = 5; /* seconds */

        theModem.atCommandSequence( "MODEM", "init" ).append( {
            "$QCSIMSTAT=1"          /* enable sim status report */
        } );

        registerAtCommandSequence( "main", "init", new AtCommandSequence( {
            """+CGEREP=2,1""",
            """+CGREG=2""",
            """+CLIP=1""",
            """+CREG=2""",
            """+COLP=0""",
            """+CSSN=1,1""",
            """+CTZU=1""",
            """+CTZR=1"""
        } ) );

        var cnmiCommand = modem_data.simBuffersSms ? """+CNMI=2,1,2,1,1""" : """+CNMI=2,2,2,1,1""";

        // sequence for when the modem is registered
        registerAtCommandSequence( "main", "registered", new AtCommandSequence( {
            cnmiCommand,
            """+CSMS=1""" /* enable SMS phase 2 */
        } ) );

        registerAtCommandSequence( "main", "suspend", new AtCommandSequence( {
            """_OSQI=0""" /* disable signal strength updates */
        } ) );

        registerAtCommandSequence( "main", "resume", new AtCommandSequence( {
            """_OSQI=1""" /* enable signal strength updates */
        } ) );
    }

    protected override void createChannels()
    {
        var transport = FsoFramework.Transport.create( modem_transport, modem_port, modem_speed );
        var parser = new FsoGsm.StateBasedAtParser();
        new AtChannel( CHANNEL_NAME, transport, parser );
    }

    protected override FsoGsm.Channel channelForCommand( FsoGsm.AtCommand command, string query )
    {
        // nothing to round-robin here as gmt601 only has one channel
        return channels[ CHANNEL_NAME ];
    }

    protected override void registerCustomMediators( HashMap<Type,Type> mediators )
    {
        Gtm601.registerCustomMediators( mediators );
    }

    protected override FsoGsm.UnsolicitedResponseHandler createUnsolicitedHandler()
    {
        return new Gtm601.UnsolicitedResponseHandler();
    }

    protected override void registerCustomAtCommands( HashMap<string,FsoGsm.AtCommand> commands )
    {

        var plusCops = theModem.createAtCommand<PlusCOPS>( "+COPS" );
        PlusCOPS.providerNameDeliveredInConfiguredCharset = true;
{'fraction_non_alphanumeric': 0.11258465011286682, 'fraction_numerical': 0.01763544018058691, 'mean_word_length': 2.7828175026680895, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5521119', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2005, 'n_words': 618}