pppd connection with GSM/GPRS modem, re-dialing after a few times - linux

I'm currently connecting my GSM/GPRS modem HUAWEI e1550 to my ISP's network. I'm able to get it connected, but after disconnecting and connecting a few times I'm not able to do it anymore, and my modem starts not to answer, and I don't no why!
I connect through pppd call tmn-3g <- my ISP conf ppp file
This is my /etc/ppp/chat file:
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 10
"" "ATZ"
OK "AT&F"
OK 'AT+CGDCONT=1,"IP","internet"'
SAY "Calling...\n"
TIMEOUT 120
OK "ATD*99***1#"
CONNECT \c
And here is my /etc/ppp/peers/tmn-3g
/dev/ttyUSB0
460800
lock
crtscts
modem
noauth
defaultroute
user tmn
password tmn
connect "/usr/sbin/chat -V -f /etc/ppp/chat-tmn-3g"
noipdefault
usepeerdns
nobsdcomp
novj
Can you help me with this?
Is it possible to restart my usb ports so that I can restart all the process?I though this could be a solution..
Or is there any other way to do it?
tks in advance..

This is more a comment than an answer (don't have comment privilege on stackoverflow...)
Seems this thread is about a similar issue.
I had a somewhat similar one as well, maybe this can help.

Related

How do I connect two computers using the same router?

I’m using the python socket module on a Mac.
How do I connect two computers using the same router? I need a TCP socket with fast data passing between.
When I tried just hooking two computers up by their private ip address, then I got a Connection Refused error. How do I do this?
You can check first whether connection is allowed between two devices by going to one device and running telnet.
telnet <Private-IP-of-Second-Device> <Port>
If this shows connected then connectivity is good and issue exists with the socket module you have written.
If this fails you can try checking the firewall by going to System Preferences > Security & Privacy > Firewall.

In PiTooth.py program after pairing from a second terminal, the program in the other terminal is still "waiting for connection"

I followed this tutorial for emulating my Raspberry pi model B as a bluetooth Keyboard. I am able to identify the pi as a keyboard when searching for connection.
The pairing part is working fine also, I am using the following command for pairing:
sudo blue-simple-agent hci0 <mac address>
The tutorial asks to run the PiTooth code in one terminal and it will initialise the required ports (control and interrupt ports), read the SDP record, advertise the sdp record and it will listen for connection in the control and interrupt port. Then open another terminal and use the above command to pair with the client.
It is getting paired but it not reflected in the other terminal, which is still like "waiting for connection. The following is the part of the python code where it is listening for connection and connecting:
class Bluetooth:
HOST = 0 # BT Mac address
PORT = 1 # Bluetooth Port Number...
def listen(self):
# Advertise our service record
self.service_handle = self. service.AddRecord(self.service_record)
print “Service record added”
# Start listening on the server sockets
self.scontrol.listen(1) # Limit of 1 connection
self.sinterrupt.listen(1)
print “Waiting for a connection”
self.ccontrol, self.cinfo = self.scontrol.accept()
print “Got a connection on the control channel from “ + self.cinfo[Bluetooth.HOST]
self.cinterrupt, self.cinfo = self.sinterrupt.accept()
print “Got a connection on the interrupt channel from “ + self.cinfo[Bluetooth.HOST]
The whole code is really big and I don't like to enlarge the question. Please view this google doc for the code:
https://docs.google.com/document/d/1hEyprvN1MyFqyczL9Qh07_-pJjRvBIEkomiJhLHcXiQ/edit?usp=sharing
Can anyone help me solve this issue. Or is there any problem with the code. Is there any alternative ways to listen for connection.
The issue is resolved. It was an out-of-box solution actually. The problem was with the operating power of the pi. The pi was powered from my laptop's USB port and it's voltage was about 4.4V. USB ports usually provide only 500 mA, 5 V. Raspberry pi need a voltage source of about 4.75 to 5.25V and current in range of 700 to 1000 mA for optimum performance. Exactly how much current (mA) the Raspberry Pi requires is dependent on what you connect to it. For reference about power supply. I just changed the source, I fetched power via a 1000 mA 5v adapter and checked the voltage in the pi, it was about 4.64V and it worked fine.

linux setup pptp vpn programmatically

I'd like to setup PPTP VPN connection in a C code under Linux. And then monitor its state, when it got offline, I want to reconnect it. But I haven't found any api for doing this. Is there any api or library to achieve this? Or any other alternative methods?
I use the following shell command to setup pptp vpn in my code.
pppd pty "pptp <vpn-host> --nolaunchpppd" user <vpn-user> password <vpn-password> lock noauth nobsdcomp nodeflate nodetach
The last option tells pppd not to run as a daemon. Then I can disconnect the vpn by killing the specific process of pppd.
And reading for the pppd standard output stream, you can get the more information about the vpn connection, like the virtual device, local-ip, remote-ip and so forth.

Disconnect a adapter

windows7, we can see different adapters in "Control Panel\Network and Internet\Network Connections", ex: 3g modem, mobile data connection, ethernet, vpn etc...I think some of these are ras connections. Say if there is a connection made on "abc modem"(ras modem) using some program given by vendor, then you can right click on adapter and disconnect.
Is there a api available for this disconnect process?
You can administratively shutdown the adapter with the SetIfEntry function. You pass a MIB_IFROW structure that you get filled with GetIfEntry before but with a changed dwAdminStatus member value.
You will need the IOCTL_NDIS_REBIND_ADAPTER ioctl call to enable the addapter again.
RasHangUp Function solved my problem. Though, i'm not so sure about consequences.
http://msdn.microsoft.com/en-us/library/aa377567(v=vs.85).aspx

Connecting to a Linux-based server over a modem

I have a black-box device with a modem attached (which I can send commands to), and would like to be able to connect to send data to a server from it. What connectivity options do I have, is PPP the protocol I need to use or is there a better option?
ppp is certainly the most common solution for getting an IP connection over a modem. There are other solutions, but there's no reason not to use PPP if what you need is an IP connection.
If you don't need an IP connection and you're writing both the client and the server, you could also do a straight serial connection from one modem to another, but that's kind of old-school.
PPP is probably your best option, if you also want an IP gateway and routing. If you only need terminal access to the device, and it runs some form of *nix, you probably have getty+serial communication as an option. You can use any number of modem terminal clients on the other side.

Resources