Connect Beaglebone black to Internet via Fona and a Sim needing APN authentication - raspberry-pi

I have a BBB, a Fona from Adafruit and a LycaMobile 3G Sim card and I wanted to connect BBB to internet using this 3G sim. I followed : this tutorial from adafruit to do so.
But to connect to my APN I need to set username and password. SO I did this :
in my /etc/ppp/peers/fona :
Instead of
noauth
I put :
auth
user lmfr
name lycamobile
and in my /etc/ppp/chap-secrets as well as in my etc/ppp/pap-secrets I put :
"lmfr" * "plus"
But I have the following error when i do this :
sudo pon fona
/usr/sbin/pppd: The remote system is required to authenticate itself
/usr/sbin/pppd: but I couldn't find any suitable secret (password) for it to use to do so
/usr/sbin/pppd: (None of the available passwords would let it use an IP address)
Does anyone knows how to fix this or another way to connect to Fona with APN authentication ?

Struggling with authentication using FONA on either Raspberry Pi 2 and 3 even while strictly following the Adafruit FONA setup instructions, the following steps helped me to get it work on both Pi's - based on a freshly installed raspbian/debian stretch OS. Adopt the following to your BBB:
update OS:
sudo apt-get update
sudo apt-get dist-upgrade
install neccessary packages:
sudo apt-get install ppp screen
connect FONA board to Pi/BBB as described within Adafruit FONA setup instructions
ensure you disabled kernel's use of hardware serial connection!
Pi2: follow Adafruit description
Pi3: "sudo raspi-config" > "Interfacing Options" > "Serial"
> "...login shell... over serial?" NO
> "...serial port hardware enabled?" YES
exit/finish raspi config and
check
sudo nano /boot/config.txt
if line enable_uart=1 is included. If not, add this as new line and save
[Ctrl]+[x], [y], [Enter] > reboot!
find the correct serial port for your Pi/BBB. This command might help - it shows all available ports:
ls /dev
Examples:
Pi2: "/dev/ttyAMA0"
Pi3: "/dev/serial0"
BBB: "/dev/tty04" (as stated at Adafruit)
Ensure that the FONA is answering on the corresponding serial port - in this example on Pi3:
screen /dev/serial0 115200
A black screen (terminal window) should occur. Write
AT [Enter]
and you should get OK as response. If you don't get the "OK", just disconnect the battery, reconnect it afterwards and give it another try! You can exit the terminal window at any time through
[Ctrl]+[A]
:quit [Enter]
As soon as the FONA board is answering over serial connection, the cellular connection (especially authentication) is the target.
Changing noauth to auth within "fona" did not help me, neither editing "chap-secrets" and/or "pap-secrets". Have the 3 APN values included within the "fona" file:
sudo -i
cd /etc/ppp/peers
nano fona
Enter the correct APN name within the "connect" line, like Adafruit mentioned:
connect "/usr/sbin/chat ... -T T-Mobile"
and replace "T-Mobile" with your APN name. Ensure to uncomment only one line within the next block, having the exact same serial port included as above when successfully testing the serial connection (in this example again the Pi3 port)
/dev/serial0
Now add the following section at the end of the file for fona-file authentication:
#Authentication
user abcd#efgh.dom << here goes the providers APN user name
password 1a2b3d4e << here goes the providers APN password
Save and exit the file and exit the superuser mode
[Ctrl]+[x], [Y], [Enter]
exit [Enter]
At least give it a try, as stated at Adafruit
sudo pon fona
If the red LED starts blinking twice every second you're done! If not, please follow the Adafruit troubleshooting section, which should solve the missing bits and pieces.
The essential parts are propper serial connection and - as soon as that works - the authentication within the "fona" file!
Especially the cellular connection and authentication should be adoptable to BBB, once the serial connection is established.

Here is what I did :
I made sure that I could see /dev/ttyO4 after adding capemgr.enable_partno=BB-UART4 to uEnv.txt
I installed ppp, screen, elinks, jdk1.8-linux-arm and librxtx-java
I used the fona library from angryelectron. So I downloaded the library on my PC and build it via "ant jar" and it generated some jar files.
I created a Main.java file in which I put this :
public class Main {
//Make sure You can see /dev/ttyO4 on your Beagle Bone Black or /dev/ttyAMA0 on raspberryPi
private static final String PORT = "/dev/ttyO4";
private static final Integer BAUD = 115200;
//Credentials for Lycamobile Wireless required for testing GPRS.
private static final String APN = "data.lycamobile.fr";
private static final String USER = "lmfr";
private static final String PWD = "plus";
private static final String SMTP = "smtp.lycamobile.fr";
public static void main(String[] args)
{
try
{
fona.open(PORT, BAUD);
testGprsHttpGet();
fona.close();
}
catch(Exception e)
{
System.out.println("exception " + e);
}
}
public static void testGprsHttpGet() throws FonaException {
System.out.println("gprsHttpGet");
fona.gprsEnable(APN, USER, PWD);
String response = fona.gprsHttpGet("http://httpbin.org/user-agent");
if (!response.contains("SIMCOM_MODULE")) {
System.out.println("Fails");
}
else{
System.out.println(response);
}
}
}
Also created a simple exec.sh file :
JAVA_OPT="-Djava.library.path=/usr/lib/jni -Dgnu.io.rxtx.SerialPorts=/dev/ttyO4"
javac -cp .:fona-0.92.jar:fona.jar:RXTXcomm-2.2pre2.jar:fona-0.92-sources.jar Main.java
java $JAVA_OPT -cp .:fona-0.92.jar:fona.jar:RXTXcomm-2.2pre2.jar:fona-0.92-sources.jar Main
I put all those files in a folder :
fona-0.92.jar fona.jar RXTXcomm-2.2pre2.jar fona-0.92-sources.jar Main.java and copied the folder on BBB
launched my script exec.sh and thats it. In the output I can see :
{
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"
}
And the NET led blinks like twice a second.
Hope this helps someone else.

Related

Can I transmit serial data only using a data cable via Raspberry pi 0 w's USB port?

I have been recently trying to find out a way whether I can send serial data (large file like image data) only through the Rpi w 0's micro USB port using ttyGS0. But when I searched online I only found ways of setting up headless through serial and other stuff which was no what I wanted. But I did follow the tutorial half way
I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line
I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space
Thinking I could just use the /dev/ttyGS0 in my serial program on the Rpi and send the data the data was being sent but on my PC when I tried to access my Rpi which was on comport 12 it said port not found and couldn't open it. But it was showing up in the device manager as 'PI USB to Serial(COM12)'
Then I wondered whether it would be possible at all to access Rpi's com port this way.
If that's the case, I want to know if there is any other way to access the Rpi's USB port only using the USB cable
Note
I don't want to use Rpi's USB as a way of logging ie. 'headless setup'. I just want to receive serial data like an Arduino.
I don't want to use the GPIO pins (I tried) as they can only send limited characters at a time and I want to send an image file. Very quickly.
I don't have any serial converters at hand so i could route it to the arduino and use /dev/ttyUSB0
then read it on PC. I just only want to use the USB cable.
In case this info is required:-
my pc is a probook 6560b running windows 7
things i found while testing and stuff:-
I did do -lsusb command but i dint find my device on that list
I tried the 'ls /dev/ttyGS0' and i found '/dev/ttyGS0'
I checked many forums and some guys were asiking to use this command 'dmesg | grep tty'and show them the code . So i performed it i dont understand what alot in the piece of text means but if it would be helpfull i pasted it here:-
pi#aloypi:~ $ dmesg | grep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[ 0.001496] printk: console [tty1] enabled
[ 2.543414] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[ 2.561791] 20215040.serial: ttyS0 at MMIO 0x20215040 (irq = 53, base_baud = 50000000) is a 16550
[ 6.716694] systemd[1]: Created slice system-getty.slice.
i also tried this one 'dmesg | grep dwc2' out of curiosity and got this but i cant say anything judging it so ya
pi#aloypi:~ $ dmesg | grep dwc2
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 bcm2708_fb.fbwidth=1366 bcm2708_fb.fbheight=768 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:6D:50:77 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 console=tty1 root=PARTUUID=4ab8bcad-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial
[ 2.379190] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[ 2.386185] dwc_otg: FIQ enabled
[ 2.386205] dwc_otg: NAK holdoff enabled
[ 2.386219] dwc_otg: FIQ split-transaction FSM enabled
[ 2.386245] Module dwc_common_port init
[ 2.968203] modules-load=dwc2,g_serial
[ 8.344134] dwc2 20980000.usb: supply vusb_d not found, using dummy regulator
[ 8.367130] dwc2 20980000.usb: supply vusb_a not found, using dummy regulator
[ 8.626751] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[ 8.647109] dwc2 20980000.usb: DWC OTG Controller
[ 8.653810] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[ 8.726672] dwc2 20980000.usb: irq 33, io mem 0x20980000
[ 8.787097] usb usb1: Manufacturer: Linux 5.10.17+ dwc2_hsotg
[ 9.371395] dwc2 20980000.usb: bound driver g_serial
[ 194.158373] dwc2 20980000.usb: new device is high-speed
[ 194.189677] dwc2 20980000.usb: new device is high-speed
[ 194.225164] dwc2 20980000.usb: new address 3
Ok looks like i made some progress
till now I did this
I went to '/boot/config.txt' and set 'dtoverlay=dwc2' at the end of the file after leaving a line
I went to '/boot/cmdline.txt' and did put 'modules-load=dwc2,g_serial' after 'rootwait' leaving a space
I did this 'sudo nano /etc/rc.local' and placed 'modeprobe g_serial use_acm=0' before 'exit 0'
Then i performed this command 'sudo systemctl stop getty#ttyGS0.service'
and then this 'sudo systemctl disable getty#ttyGS0.service'
(i think disabling getty#ttyGS0.service and puting 'modeprobe g_serial use_acm=0' in the folder metioned above allowed rpi and pc to comunicate but then again i can be wrong )
then perfored a 'sudo reboot'
this seemed to solve my problem
but i have one more problem now
whatever is sent from the rpi i can only recieve in the coolterm serial port reading software
i cant seem to use read the port from processing for some reason
(im using processing to later read the image file being sent)
here is my current serial reading program in processing
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup()
{
myPort = new Serial(this, "COM13", 115200);
}
void draw()
{
if ( myPort.available() > 0)
{ // If data is available,
val = myPort.readStringUntil('\n'); // read it and store it in val
}
if (val!=null)
{
println(val); //print it out in the console
}
}
i kinda am stuck here :P
EDIT
welp nevermind i solved it
i finally finally got it working yaaaaaaaayyy
OK now remember all who seek for the answer when using /dev/ttyGS0 it uses the CTS and RTS protocall
(now idk if it can be disabled but please lemme know you guys)
Its like the pi asks your pc wether it is cleared to send the data and when the pc says yeah ok send the data the pi sends it
so whenever your using this method please enable rts or cts
this is what i used in processing to recieve the data
import processing.serial.*;
Serial myPort;
void setup()
{
//remember to set the COM port to which your pi is set
size(200, 200);
myPort = new Serial(this, "COM13", 115200);
}
void draw()
{
if ( myPort.available() > 0)
{
if(myPort.getCTS()==true){
myPort.setRTS(true);
print(myPort.read());
}
}
}
i hope this is of loadsa help to you guys but if there is some correction needed please lemme know yall:D
thanks

Connect Retroflag GPi (Raspberry Pi Zero W) to WPA2 Enterprise

I just got my retroflag gpi case working and set up. I have one small problem though. I can't connect my Pi to my WPA2-Enterprise network. I've tried a bunch of settings in wpa_supplicant.conf but can't get it to work.
Pi Model or other hardware: Raspberry Pi Zero W & Retroflag GPi Case
Power Supply used: Retroflag GPi's inbuilt.
RetroPie Version Used: 4.6.1
Built From: https://github.com/RetroPie/RetroPie-Setup/releases/download/4.6/retropie-buster-4.6-rpi1_zero.img.gz
USB Devices connected: Retroflag GPi
Controller used: Retroflag GPi
Error messages received:
Can't see any error messages. Don't know where they appear. It just says IP-address Unkown in show ip.
Guide used: Several on Google. This one among others: https://gist.github.com/elec3647/1e223c02ef2a9a3f836db7984011b53b.
This one for documentation: https://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf
File: /etc/wpa_supplicant/wpa_supplicant.conf
Attachment of config files: (wpa_supplicant.conf)
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=SE
ap_scan=1
network={
ssid="Wifi-Name"
scan_ssid=1
identity="myusername"
password="mypassword"
key_mgmt=WPA-EAP
eap=TTLS
phase1="peapver=0 peaplabel=1"
phase2="autheap=MSCHAPV2"
}
I actually solved it just now.
For anyone wondering I managed to connect to the network on another machine (Ubuntu) and used Network Manager. I then checked the log (according to this link) with the command:
journalctl -u NetworkManager
This gave me this config for wpa_supplicant.conf:
country=SE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
ap_scan=1
network={
ssid="Wifi-Name"
scan_ssid=1
bgscan="simple:30:-65:300"
key_mgmt=WPA-EAP WPA-EAP-SHA256
password="password"
eap=PEAP
fragment_size=1266
phase2="auth=MSCHAPV2"
identity="username"
proactive_key_caching=1
}
This might not work for everyone else since the configs are always different for every network. So be sure to do the same steps as I did if you can't get it to work.
So glad I finally got this, haha.

It is impossible to create a new session because 'createSession' which takes HttpClient,

org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
I am getting this error randomly i want to know the route cause for this issue in IOS
There are multiple reason behind this issue. There are multiple ways to resolve this issues, depending upon, where these issues are coming from.
1)One issue which occur to me was DesireCapabilities.setCapability() key/value was not correct type. I have resolved this issue by just
DesiredCapabilities.setCapability("capabilities_variable","capabilities_value");
setCapability("appWaitDuration", "600000"); here 600000 was String instead of long or int
Check your setCapability type whether it String/int/long.
2) Check USB Connection is Laptop or Computer, if not connected than same issue.
3) ADB Server might be problem. So adb kill-server and adb start-server
4) Try to change USB and try it out.
5) Sometimes, it might be a proxy issue(Laptop/Desktop may have some proxy setup
in organization, since for Desktop/Laptops are connected with Mobile via TCP/IP Connection).
6) Sometimes, there might be permission required to access PORT (sudo ufw allow portnumber (UBUNTU SYSTEM))
7) Environment variable required Android_SDK_Home and Android Platform Tools path
**> Solution 1st**
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "xyz");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", Platform.ANDROID);
capabilities.setCapability("appPackage", "com.hp.HPSupportAssistant");
capabilities.setCapability("appActivity", "com.hp.HPSupportAssistant.MainActivity");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 6000); capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS,true);
//desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
**Here comment below line and then run it will work**
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
**solution 2nd Or keep above line in desired capabilities but before that do
run 3 cmd on cmd promt**
adb shell pm list packages -f > D://t.txt
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);

Cannot send command IR with HotPI

I bought a HotPi a while ago, and decided to use it. So I followed the procedure to configure the IR and after a few hours I was able to IR signals on my Raspberry 1.
But my purpose here is to send IR signals, which I tried, without any luck.
So this is the command I try to do (just for test):
irsend SEND_START devinput KEY_POWER ; sleep 3
And this is what lircd tells me:
lircd-0.9.4c[907]: Notice: accepted new client on /var/run/lirc/lircd
lircd-0.9.4c[907]: Info: Cannot configure the rc device for /dev/lirc0
lircd-0.9.4c[907]: Error: invalid send buffer
lircd-0.9.4c[907]: Error: this remote configuration cannot be used to transmit
lircd-0.9.4c[907]: Error: error processing command: SEND_START devinput KEY_POWER
lircd-0.9.4c[907]: Error: transmission failed
lircd-0.9.4c[907]: Info: removed client
Edit:
It seems I'm not using the good drivers. According to the HotPi documentation, I'm suppose to use lirc-rpi, which I'm suppos to install with
sudo modprobe lirc-rpi
Which, at least, doesn't return an error. But trying to configure the interface tells me that the driver doesn't exist:
pi#raspberrypi:~ $ mode2 --driver lirc-rpi --device /dev/lirc0
Driver `lirc-rpi' not found. (Missing -U/--plugins option?)
Available drivers:
accent
alsa_usb
asusdh
atilibusb
atwf83
audio
audio_alsa
awlibusb
bte
bw6130
commandir
creative
creative_infracd
default
devinput
dfclibusb
dsp
dvico
ea65
file
ftdi
ftdi-exp
ftdix
girs
i2cuser
irlink
irtoy
livedrive_midi
livedrive_seq
logitech
macmini
mouseremote
mouseremote_ps2
mp3anywhere
mplay
mplay2
pcmak
pinsys
pixelview
samsung
sb0540
silitek
slinke
sonyir
srm7500libusb
tira
tira_raw
udp
uirt2
uirt2_raw
usb_uirt_raw
usbx
zotac
Here is no info what lirc version you are using. There are vast differences between the legacy 0.9.0 still used in some distros and modern lirc.
That said, the logs seems pretty clear. You are using the devinput driver, right? This driver does not support sending data, reflecting the fact that also the kernel doesn't.
You then need to use another driver - first stop might be the default one. If/when using this other driver, you need another lircd.conf.
Please refer to http://lirc.org/html/configuration-guide.html
EDIT: Ah, lirc-0.9.4c says the log. Sorry, my bad. The reply should still be valid, though.
When you record the remote, use:
irrecord -d /dev/lirc0 -f name.conf
The -f uses raw mode. This then worked for me on the transmit side, before I got same error as you.

python-memcache memcached -- I installed on centos virtualbox but it get/set never seem to work

I'm using python. I did a yum install memcached followed by a easy_install python-memcached
I used the simple test program from the Help(memcache). When I wasn't getting the proper answers I threw in some print statements:
[~/test]$ cat m2.py
import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
x = mc.set("some_key", "Some value")
print 'Just set a key and value into the cache (suposedly)'
value = mc.get("some_key")
print 'Just retrieved that value from the cache using the key'
print 'X %s' % x
print 'Value %s' % value
[~/test]$ python m2.py
Just set a key and value into the cache (suposedly)
Just retrieved that value from the cache using the key
X 0
Value None
[~/test]$
The question now is, what have I failed to do in my installation? It appears to be working from an API perspective but it fails to put anything into the memcache share area.
I'm using a virtualbox vm running centos
[~]# cat /proc/version
Linux version 2.6.32-358.6.2.el6.i686 (mockbuild#c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Thu May 16 18:12:13 UTC 2013
Is there a daemon that is supposed to be running? I don't see an obvious named one when I do a ps.
I tried to get pylibmc installed on my vm but was unable to find a working installation so for now will see if I can get the above stuff working first.
I discovered if i ran straight from the python console GUI i get a bit more output if I set debug=1
>>> mc = memcache.Client(['127.0.0.1:11211'], debug=1)
>>> mc.stats
{}
>>> mc.set('test','value')
MemCached: MemCache: inet:127.0.0.1:11211: connect: Connection refused. Marking dead.
0
>>> mc.get('test')
MemCached: MemCache: inet:127.0.0.1:11211: connect: Connection refused. Marking dead.
When I try to use per the example telnet to connect to the port i get a connection refused:
[root#~]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
[root#~]#
I tried the instructions I found on the net for configuring telnet so localhost wouldn't be disabled:
vi /etc/xinetd.d/telnet
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
And then ran the commands to restart the service(s):
service iptables stop
service xinetd stop
service iptables start
service xinetd start
service iptables stop
I ran with both cases (iptables started and stopped) but it has no effect. So I am out of ideas. What do I need to do to make it so the PORT will be allowed? if that is the problem?
Or is there a memcached service that needs to be running that needs to open up the port ?
well this is what it took to get it working: ( a series of manual steps )
1) su -
cd /var/run
mkdir memcached # this was missing
In the memcached file I added "-l 127.0.0.1" to the OPTIONS statement. It's apparently a listen option. Do this for steps 2 & 3. I'm not certain which file is actually used at runtime.
2) cd /etc/sysconfig
cp memcached memcached.old
vi memcached
3) cd /etc/init.d
cp memcached memcached.old
vi memcached
4) Try some commands to see if the server starts now
/etc/init.d/memcached start
/etc/init.d/memcached status
/etc/init.d/memcached stop
/etc/init.d/memcached restart
I tried opening a browser, but it never seemed to actually display anything so I don't really know how valid this approach is. I'm not running apache or anything like this so perhaps its not relevant to my cause. Perhaps I would have to supply a ?key=blah or something.
5) http://127.0.0.1:11211
6) Now it should be ready to go. If one runs the test shown with the following it should work. At least it did for me. doing the help(memcache) will display a simple program. just paste that in and it should work just fine.
[~]$ python
>>> import memcache
>>> help(memcache)