HiPi
Perl Modules for Raspberry Pi
Version 0.80 - released 22 July 2019

HiPi::Huawei::E3531

The Huawei HiLink modules provide access to the HTTP API for Huawei USB modems. The E3531 modem is specifically supported but the modules may work for other Huawei USB dongles that provide the HiLink HTTP interface.

The modules provide access to the HiLink API which is not the same as accessing the dongle through AT commands over a serial device.

The API allows you read and send SMS messages, start and stop your data connection and monitor your data usage. This module provides the interface for the only currently tested USB device.

Data Connection Notes

( Notes on managing your data connection )

General Method Responses

All methods except the new constructor return a response hash. If the response contains the element code then there has been an error. Details of the error may be in the message element of the response.

use HiPi qw( :hilink );
use HiPi::Huawei::E3531;
my $hlink = HiPi::Huawei::E3531->new();

my $response = $hlink->get_data_status();
if($reponse->{code}) {
    # there is an error
    say qq(Error Code:    $reponse->{code});
    say qq(Error Message: $reponse->{message});
}

The code returned may be an error code from the HiLink API itself or it may be an HTTP response code if there is some problem with connection to the API. For example the response may contain the following:

$reponse = {
    code    => 500,
    message => "Unable to get session info : 500 Can't connect to 192.168.8.1:80"
};

A successful response will never contain a code element.

Requests that successfully return information contain the information in the response hash.

$response = $hilink->get_network();
$response = {
    'Rat' => '2',
    'FullName' => 'O2 - UK',
    'ShortName' => 'O2 - UK',
    'State' => '0',
    'Numeric' => '56798'
};

Successful command requests return a simple success hash

$response = $hilink->send_sms('+441234567890', 'Hello, hello, is there anybody there?');
$response = {
    'success' => 'OK',
};

A successful request or command will never return a code element in the response. A request or command that encounters an error will always return a code element in the reponse.

Methods

Create a new instance of the class

use HiPi qw( :hilink );
use HiPi::Huawei::E3531;

my $hlink = HiPi::Huawei::E3531->new();

The HiPi::Huawei::E3531 uses a default ip address 0f 192.168.8.1 for the modem interface. If you are experimenting with the modules for use with a different model, you may specify a different ip address in the contructor.

my $hlink = HiPi::Huawei::E3531->new( ip_address => '192.168.1.1' );

If you specify 'debug' in the constructor, the modules will dump full request and respose details to STDOUT.

my $hlink = HiPi::Huawei::E3531->new( debug => 1 );

If your E3531 has a password set, many of the methods require you to login.

The login method can be called routinely in your code as it will only attempt to login if your device requires it.

The default username and password for the E3531 are 'admin' and 'admin'.

$response = $hilink->login('admin','admin');

Successful $response is a success hash

$response = { 'success' => 'OK' };

You should not need to logout unless you have a long running session that times out. The logout method logs you out of the API and clears your session.

$response = $hilink->logout();

Successful $response is a success hash

$response = { 'success' => 'OK' };

Connect modem to the network

$response = $hilink->connect_modem();

Successful $response is a success hash

$response = { 'success' => 'OK' };

See : Data Connection Notes

Disconnect modem from the network

$response = $hilink->disconnect_modem();

Successful $response is a success hash

$response = { 'success' => 'OK' };

See : Data Connection Notes

Set mobile data on

$response = $hilink->set_data_on();

Successful $response is a success hash

$response = { 'success' => 'OK' };

See : Data Connection Notes

Set mobile data off

$response = $hilink->set_data_off();

Successful $response is a success hash

$response = { 'success' => 'OK' };

See : Data Connection Notes

Get the basic status of the modem

my $response = $hlink->get_status();

On success, the returned $response will be a hash with the keys as follows:

$response = {
  'BatteryLevel' => '',
  'BatteryPercent' => '',
  'BatteryStatus' => '',
  'cellroam' => '0',
  'classify' => 'hilink',
  'ConnectionStatus' => '901',
  'CurrentNetworkType' => '4',
  'CurrentNetworkTypeEx' => '41',
  'CurrentServiceDomain' => '3',
  'currenttotalwifiuser' => '0',
  'CurrentWifiUser' => '',
  'flymode' => '0',
  'maxsignal' => '5',
  'PrimaryDns' => '82.132.254.2',
  'PrimaryIPv6Dns' => '',
  'RoamingStatus' => '0',
  'SecondaryDns' => '82.132.254.3',
  'SecondaryIPv6Dns' => '',
  'ServiceStatus' => '2',
  'SignalIcon' => '5',
  'SignalStrength' => '',
  'simlockStatus' => '0',
  'SimStatus' => '1',
  'TotalWifiUser' => '',
  'WanIPAddress' => '10.126.75.38',
  'WanIPv6Address' => '',
  'WifiConnectionStatus' => '',
  'wififrequence' => '0',
  'wifiindooronly' => '-1',
  'WifiStatus' => ''
};

Of particular interest is the ConnectionStatus value that indicates the current data connection status.

You can import the following constants to check the current value of ConnectionStatus

use HiPi qw( :hilink );

  • HILINK_CONNSTATUS_CONNECTING    ( 900, connecting )
  • HILINK_CONNSTATUS_CONNECTED    ( 901, connected )
  • HILINK_CONNSTATUS_DISCONNECTED    ( 902, disconnected )
  • HILINK_CONNSTATUS_DISCONNECTING    ( 903, disconnecting )

See : Data Connection Notes

Get the current mobile data status of the modem.

$response = $hilink-get_data_status();

On success, the returned $response will be a hash with the value dataswitch:

$response = {
    'dataswitch' => '0'
};
  • dataswitch == 0 : mobile data is switched off
  • dataswitch == 1 : mobile data is switched on

See : Data Connection Notes

Return the contents of the SMS inbox.

$response = $hilink->get_inbox();

Successful $response will contain hash with the following values

$response = {
  'BoxType' => 1,
  'Count' => '2',
  'Messages' => [
    {
      'Content' => 'Good day dongle',
      'Date' => '2019-04-13 13:27:46',
      'Index' => '40001',
      'Phone' => '+441234567890',
      'Priority' => '0',
      'SaveType' => '4',
      'Sca' => '',
      'Smstat' => '0',
      'SmsType' => '1'
    },
    {
      'Content' => 'Hello dongle',
      'Date' => '2019-04-13 13:27:11',
      'Index' => '40000',
      'Phone' => '+441234567890',
      'Priority' => '0',
      'SaveType' => '4',
      'Sca' => '',
      'Smstat' => '1',
      'SmsType' => '1'
    }
  ]
};

Messages with an Smstat value of 0 are unread. You can mark a message as read by calling
$hilink->set_sms_read( $index )
using the Index value of the message.

You can delete a message by calling
$hilink->delete_sms( $index )
using the Index value of the message.

Returns the contents of the SMS outbox

$response = $hilink->get_outbox();

Successful $response will contain hash with the following values

$response = {
  'BoxType' => 2,
  'Count' => '2',
  'Messages' => [
    {
      'Content' => 'Good day world',
      'Date' => '2019-04-13 13:31:39',
      'Index' => '40003',
      'Phone' => '+441234567890',
      'Priority' => '4',
      'SaveType' => '3',
      'Sca' => '',
      'Smstat' => '3',
      'SmsType' => '1'
    },
    {
      'Content' => 'Hello World',
      'Date' => '2019-04-13 13:30:52',
      'Index' => '40002',
      'Phone' => '+441234567890',
      'Priority' => '4',
      'SaveType' => '3',
      'Sca' => '',
      'Smstat' => '3',
      'SmsType' => '1'
    }
  ]
};

You can delete a message by calling
$hilink->delete_sms( $index )
using the Index value of the message.

Returns ant draft messages stored on your device

$response = $hilink->get_drafts();

Successful $response will contain hash with the following values

$response = {
  'BoxType' => 3,
  'Count' => '1',
  'Messages' => [
    {
      'Content' => 'I am creating a message but I do not know who to send it to yet',
      'Date' => '2019-04-13 13:33:41',
      'Index' => '40004',
      'Phone' => '',
      'Priority' => '4',
      'SaveType' => '3',
      'Sca' => '',
      'Smstat' => '2',
      'SmsType' => '1'
    }
  ]
};

You can delete a message by calling
$hilink->delete_sms( $index )
using the Index value of the message.

You can send SMS messages to one or more recipients using this method.

$recipients can be a string containing the recipient number or a reference to an array of strings containing multiple numbers.

$message must be a Perl string containing your message. Do not pass encoded octets. The SMS will be sent as 1 or more GSM 03.38 encoded texts if all characters can be represented in the GSM 03.38 encoding.

If all characters cannot be represented in the GSM 03.38 encoding the SMS will be sent as 1 or more texts encoded as UCS-2. When encoding as UCS-2, any characters that cannot be encoded are replaced with '?'.

You can force encoding in GSM 03.38 by setting the following flag:
$hilink->force_gsm(1)
If this flag is set, the message is encoded as GSM 03.08 with any characters that cannot be encoded replaced with '?'.

$response = $hilink->send_sms( '+441234567890', 'Hello there' );
$response = $hilink->send_sms( [ '+441234567890', '+440987654321' ], 'Hello to all of you' );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Set an SMS message in the inbox as read using its 'Index' value.

$response = $hilink->set_sms_read( 40001 );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Delete an SMS message using its 'Index' value.

$response = $hilink->delete_sms( 40001 );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Provides a list of SMS message counts. Onlt the 'Local' values seem useful.

$response = $hilink->get_sms_count();

On success $response is a hash containing the following values.

$response = {
  'LocalDeleted' => '0',
  'LocalDraft' => '1',
  'LocalInbox' => '2',
  'LocalMax' => '500',
  'LocalOutbox' => '2',
  'LocalUnread' => '1',
  'NewMsg' => '1',
  'SimDraft' => '0',
  'SimInbox' => '0',
  'SimMax' => '10',
  'SimOutbox' => '0',
  'SimUnread' => '0',
  'SimUsed' => '0'
};

Returns basic information about your device.

$response = $hilink->get_basic_info();

On success $response is a hash containing the following values.

$response = {
  'classify' => 'hilink',
  'devicename' => 'E3531',
  'multimode' => '0',
  'productfamily' => 'GW',
  'restore_default_status' => '1',
  'sim_save_pin_enable' => '0'
);

Returns information about your device

$response = $hilink->get_device_info();

On success $response is a hash containing the following values.

$response = {
  'Classify' => 'hilink',
  'DeviceName' => 'E3531',
  'HardwareVersion' => 'CU1E3131IM',
  'Iccid' => 'XXXXXXXXXXXXXXXXXXXX',
  'Imei' => 'XXXXXXXXXXXXXXX',
  'Imsi' => 'XXXXXXXXXXXXXXX',
  'MacAddress1' => 'BA:AB:BE:34:00:00',
  'MacAddress2' => '',
  'Msisdn' => '',
  'ProductFamily' => 'GW',
  'SerialNumber' => 'XXXXXXXXXXXXXXXX',
  'SoftwareVersion' => '22.521.31.00.400',
  'supportmode' => 'WCDMA|GSM',
  'WebUIVersion' => '17.100.14.00.400',
  'workmode' => 'WCDMA'
};

A wrapper around get_device_info() to return just the serial number.

$response = $hilink->get_serial_number();

On success $response is a hash containing the following values.

$response = {
  'SerialNumber' => 'XXXXXXXXXXXXXXXX',
};

Provides current notification status. Assume the HiLink web app must display notifications.

$response = $hilink->check_notifications();

On success $response is a hash containing the following values.

$response = {
  'OnlineUpdateStatus' => '10',
  'SmsStorageFull' => '0',
  'UnreadMessage' => '1'
};

Returns the connection information. Some of these values can be set in the HiLink web app.

$response = $hilink->get_connection_info();

On success $response is a hash containing the following values.

$response = {
  'auto_dial_switch' => '1',
  'ConnectMode' => '0',
  'MaxIdelTime' => '7200',
  'MTU' => '1500',
  'pdp_always_on' => '0',
  'RoamAutoConnectEnable' => '0'
};

Get current network information

$response = $hilink->get_network();

On success $response is a hash containing the following values.

$response = {
  'FullName' => 'O2 - UK',
  'Numeric' => '23410',
  'Rat' => '2',
  'ShortName' => 'O2 - UK',
  'State' => '0'
};

Get current signal information

$response = $hilink->get_signal_info();

On success $response is a hash containing the following values.

$response = {
  'cell_id' => '28709825',
  'ecio' => '-5dB',
  'mode' => '2',
  'pci' => '',
  'psatt' => '1',
  'rscp' => '-76dBm',
  'rsrp' => '',
  'rsrq' => '',
  'rssi' => '-71dBm',
  'sc' => '47',
  'sinr' => ''
};

Reboot the device. You will loose access to the device while it reboots.

$response = $hilink->device_reboot();

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Shut down the device. This will disconnect the modem.

$response = $hilink->device_shutdown();

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Restore all settings to the factory defaults. You will lose all your SMS information, traffic settings and the admin password will be reset to the default.

Note that if the device is password protected, you will need to login to access this method. This means this method cannot be used to recover from a forgotten password.

$response = $hilink->device_restore();

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

If your device is password protected, and you have forgotten your password, the device_restore method is not available to you. This method allows you to reset the device to factory defaults including the password by passing the Serial Number of your device.

Note that as with the device_restore method all of your SMS data and any settings will be lost.

$response = $hilink->device_serial_restore( $sn );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

WARNING: Not all versions of the E3531 firmware implement this method so it seems possible that if you change the password and forget it, an E3531 that does not have this method would be permanently locked.

Returns the current login status of this session.

If 'State' is 0 then either no login is required or the current session is already logged in.

You should not need to call this method yourself. The login method calls this method first to see if login is actually required.

$response = $hilink->get_login_status();

On success $response is a hash containing the following values.

$response = {
  'password_type' => '0',
  'State' => '0',
  'Username' => ''
};

Returns if the device is set to require a login to access methods such as send_sms or get_inbox

$response = $hilink->get_login_required();

On success $response is a hash containing the following values.

$response = {
  'hilink_login' => '0'
};

Whether the device requires login can be set by calling set_password_required( $bool )

Sets if the device requires a password or not. Pass 1 to switch on, 0 to switch off.

If the device currently requires a password, you must be logged in to call this method.

For some versions of the E3531 the HiLink web app does not allow modification of the password or setting the password required. This may be because if you forget the password there appears to be no way to reset the device if the device_serial_restore method is not implemented.

This module will check if your E3531 HiLink web app allows modification of passwords and therefore supports device_serial_restore. If it does not then calling this method will return an error.

If you want to ignore this safety measure and use passwords on such a device, you can override the safety in the module constructor but be aware that if you change a password and forget it then you will be locked out of your device.

If your device doesn't support device_serial_restore then you must also be certain that the default password is still 'admin' before you switch passwords on. If it isn't, you will be locked out.

$response = $hilink->set_password_required( 1 );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

To override safety and use passwords on a device that does not support device_serial_restore

my $hilink = HiPi::Huawei::E3531->new( safety => 0 );
$response = $hilink->set_password_required( 1 );

If you are using passwords you can change the admin user password using this method.

$response = $hilink->change_password( 'admin', 'admin', 'foobar' );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

For some versions of the E3531 the HiLink web app does not allow modification of the password or setting the password required. This may be because if you forget the password there appears to be no way to reset the device if the device_serial_restore method is not implemented.

This module will check if your E3531 HiLink web app allows modification of passwords and therefore supports device_serial_restore. If it does not then calling this method will return an error.

If you want to ignore this safety measure and change passwords on such a device, you can override the safety in the module constructor but be aware that if you change a password and forget it then you will be locked out of your device.

To override safety and change passwords on a device that does not support device_serial_restore

my $hilink = HiPi::Huawei::E3531->new( safety => 0 );
$response = $hilink->change_password( 'admin', 'admin', 'foobar' );

Called by set_password_required and change_password methods, this method returns if the HiLink web app allows modification of the password settings and therefore if it is safe for this module to alter password settings.

$response = $hilink->hilink_can_modify_password();

On success $response is a hash containing the following values.

$response = {
  'hilink_can_modify_password' => 1
};

Returns data traffic statistics

$response = $hilink->get_traffic_stats();

On success $response is a hash containing the following values.

$response = {
  'CurrentConnectTime' => '5228',
  'CurrentDownload' => '855860',
  'CurrentDownloadRate' => '0',
  'CurrentUpload' => '39372',
  'CurrentUploadRate' => '0',
  'showtraffic' => '1',
  'TotalConnectTime' => '153276',
  'TotalDownload' => '1584965',
  'TotalUpload' => '312808'
};

Return data traffic statistics for the current month as defined in the data plan.

$response = $hilink->get_month_stats();

On success $response is a hash containing the following values.

$response  = {
  'CurrentMonthDownload' => '1510753',
  'CurrentMonthUpload' => '270231',
  'MonthDuration' => '122297',
  'MonthLastClearTime' => '2019-4-11'
};

Reset all traffic counters to zero

$response = $hilink->clear_traffic();

On success $response is a hash containing the following values.

$response  = { success => 'OK' };

Returns the current monthly data plan stored on the device as set in the HiLink web app.

$response = $hilink->get_data_plan();

On success $response is a hash containing the following values.

$response  = {
  'DataLimit' => '3GB',
  'DataLimitAwoke' => '0',
  'MonthThreshold' => '95',
  'MonthThresholdSecond' => '0',
  'SetMonthData' => '1',
  'StartDay' => '1',
  'trafficmaxlimit' => '3221225472',
  'turnoffdataenable' => '0',
  'turnoffdataflag' => '0',
  'turnoffdataswitch' => '0'
};

Set the data plan details

$day : a day number between 1 and 31

$limit : monthly limit. Append the suffix 'MB' or 'GB' to a number

$threshold : notification threshold percentage. A number between 1 and 100

$response = $hilink->set_data_plan( 2, '3GB', 95 );

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

Turn the data plan off

$response = $hilink->set_data_plan_off();

On success $response is a hash containing the following values.

$response = { 'success' => 'OK' };

If you investigate the HiLink API further and find additional useful resources, you can access them using the generic_get method.

$response = $hilink->generic_get( 'api/device/basic_information' );

On success $response is a hash containing the values returned from the call. For example

$response = {
  'classify' => 'hilink',
  'devicename' => 'E3531',
  'multimode' => '0',
  'productfamily' => 'GW',
  'restore_default_status' => '1',
  'sim_save_pin_enable' => '0'
};

If you investigate the HiLink API further and find additional useful resources, you can set them using the generic_post_xml method.

my $resource = 'api/sms/delete-sms';
my $xml = q(<?xml version="1.0" encoding="UTF-8"?>
<request>
<Index>40046</Index>
</request>);
my $response = $hilink->generic_post_xml( $resource, $xml );

On success $response is a hash containing the values returned from the call. For example

$response = { 'success' => 'OK' };

Retrun the data profile information

$response = $hilink->get_profiles();

On success $response is a hash containing the following values

$response  = {
  'CurrentProfile' => '1',
  'Profiles' => [
    {
      'ApnIsStatic' => '1',
      'ApnName' => 'mobile.o2.co.uk',
      'AuthMode' => '1',
      'DialupNum' => '*99#',
      'DnsIsStatic' => '0',
      'Index' => '1',
      'IpAddress' => '',
      'IpIsStatic' => '0',
      'iptype' => '0',
      'Ipv6Address' => '',
      'IsValid' => '1',
      'Name' => 'O2PAYMONTHLY',
      'Password' => '',
      'PrimaryDns' => '',
      'PrimaryIpv6Dns' => '',
      'ReadOnly' => '2',
      'SecondaryDns' => '',
      'SecondaryIpv6Dns' => '',
      'Username' => 'o2web'
    },
    {
      'ApnIsStatic' => '1',
      'ApnName' => 'm-bb.o2.co.uk',
      'AuthMode' => '1',
      'DialupNum' => '*99#',
      'DnsIsStatic' => '0',
      'Index' => '2',
      'IpAddress' => '',
      'IpIsStatic' => '0',
      'iptype' => '0',
      'Ipv6Address' => '',
      'IsValid' => '1',
      'Name' => 'O2PAYG',
      'Password' => '',
      'PrimaryDns' => '',
      'PrimaryIpv6Dns' => '',
      'ReadOnly' => '2',
      'SecondaryDns' => '',
      'SecondaryIpv6Dns' => '',
      'Username' => 'o2bb'
    },
  ]
};

Get the fixed device configuration. This appears to determine what is available in the HiLink web app.

$response = $hilink->get_deviceinfo_config();

On success $response is a hash containing the values returned from the call. For example

$response = {
  'cell_id' => '0',
  'classify' => '0',
  'devicename' => '1',
  'ecio' => '0',
  'esn' => '0',
  'hardwareversion' => '1',
  'iccid' => '0',
  'imei' => '1',
  'imsi' => '1',
  'macaddress1' => '1',
  'macaddress2' => '0',
  'meid' => '0',
  'msisdn' => '1',
  'pci' => '0',
  'productfamily' => '0',
  'rscp' => '0',
  'rsrp' => '0',
  'rsrq' => '0',
  'rssi' => '0',
  'sc' => '0',
  'serialnumber' => '0',
  'sinr' => '0',
  'softwareversion' => '1',
  'wanipaddress' => '1',
  'wanipv6address' => '0',
  'webuiversion' => '1'
};

Get the fixed global configuration. This appears to determine what is available in the HiLink web app.

$response = $hilink->get_global_config();

On success $response is a hash containing the values returned from the call. For example

$response = {
  'ap_station_enabled' => '0',
  'appmanagements' => {
    'enabled' => '0',
    'mobileDoctor' => {
      'linuxOS' => '',
      'macOS' => '',
      'windowsOS' => ''
    },
    'mobileWifi' => {
      'android' => 'http://consumer.huawei.com/minisite/mobilewifiapp/apk/HuaweiMobileWiFi.apk',
      'ios' => 'https://itunes.apple.com/app/huawei-mobile-wifi/id546979875?ls=1&mt=8',
      'windows' => ''
    }
  },
  'autoapn_enabled' => '0',
  'battery_enabled' => '0',
  'connection' => {
    'connectionstatus' => '1',
    'enable' => '1'
  },
  'continue_button' => '1',
  'copyright' => '2016',
  'default_language' => '',
  'dialogdisapear' => '3000',
  'footer' => '1',
  'homepage' => '',
  'hotlinks' => {
    'enable' => '1',
    'items' => {
      'item' => [
        '',
        '',
        ''
      ]
    }
  },
  'login' => '0',
  'menu' => {
    'appmanagement' => 'appmanagement',
    'home' => 'home',
    'pb' => 'phonebook',
    'settings' => {
      'cbssettings' => 'cbssettings',
      'dialup' => {
        'mobileconnection' => 'mobileconnection',
        'mobilenetworksettings' => 'mobilenetworksettings',
        'profilesmgr' => 'profilesmgr'
      },
      'security' => {
        'pincodemanagement' => 'pincodemanagement'
      },
      'system' => {
        'deviceinformation' => 'deviceinformation',
        'modifypassword' => 'modifypassword',
        'reboot' => 'reboot',
        'restore' => 'restore',
        'systemsettings' => 'systemsettings'
      }
    },
    'sharing' => 'sdcardsharing',
    'sms' => {
      'drafts' => 'smsdrafts',
      'inbox' => 'smsinbox',
      'sent' => 'smssent',
      'sms_center_number' => 'messagesettings'
    },
    'statistic' => 'statistic',
    'stk' => 'stk',
    'update' => 'update',
    'ussd' => {
      'postpaid' => {
        'post_fun_balanceInquiry' => 'balanceInquiry',
        'post_fun_charge' => 'charge',
        'post_fun_general' => 'general',
        'post_service_title' => 'activate_internet_service'
      },
      'prepaid' => {
        'pre_fun_balanceInquiry' => 'balanceInquiry',
        'pre_fun_charge' => 'charge',
        'pre_fun_general' => 'general',
        'pre_service_title' => 'activate_internet_service'
      }
    }
  },
  'menu_number' => '5',
  'position_info' => {
    'offset' => '0',
    'offset_ie6' => '0'
  },
  'roam_warn_enabled' => '1',
  'special_redirect' => '1',
  'tip_disapear' => '3000',
  'title' => 'HiLink',
  'update_interval' => '3000'
};



Data Connection Notes

return to method list

To connect to the internet

  • Data must be switched on
  • You must be connected to the network

To switch data on

my $response = $hilink->set_data_on();

To connect to network

my $response = $hilink->connect_modem();

If data is switched on the modem will connect on demand anyway, disconnecting after the configured inactivity period has passed.

You may disconnect the modem yourself using the command

my $response = $hilink->disconnect_modem();

The modem will connect again on demand unless you switch data off

my $response = $hilink->set_data_off();

Even if data is switched off and the modem is disconnected, the interface and default routes will still be configured. To remove the interface completely you have to identify the interface that connects to the USB modem. Testing on a Pi3+ which has its own ethernet interface, the USB modem always configured as eth1. You may develop a more precise way of identifying the interface by, for example, creating udev rules or looking for the IP4 MAC address, which for the E3531 always appears to be 00:1e:10:1f:00:00

my $response = $hilink->disconnect_modem();
$response = $hilink->set_data_off();
system(sudo ifconfig eth1 down);

To bring the interface back up

system(sudo ifconfig eth1 up);
sleep 5; # wait for interface
my $response = $hilink->set_data_on();
$response = $hilink->connect_modem();