Initial Connection for network setup from Smartphone to raspberry - raspberry-pi3

I have Raspberry Pi 3 model B
OS: Raspbian(jessie)
I want to create a connection from my smartphone to a headless raspberry, and connect the headless raspberry to a network(which the smartphone is conencted).
like the vacum cleaner robot (IRobot) or Web camera which has an app, or any device that needs an initial connection to setup it's network.
the initial connection needs to be from a remote device, mainly a smartphone app.
What did i try:
1. bluetooth - i've managed to setup the bluetooth in the raspberry. when i try to connect, a popup appears on the raspberry which ask to confirm connection, because the raspberrry needs to be headless, this option is not good for us.
if i set the bluetooth as follow: sudo hciconfig hci0 sspmode 0
when i try to connect to the raspberry, a popup appears in the smartphone required a PIN code, this option may be good, if i new the PIN code.
2. P2P - i try use wifi direct from my smartphone
i've create file called p2p.conf inside /etc/wap_supplicant
inside this file i wrote the following:
ctrl_interface/var/run/wpa_supplicant
update_config=1
device_name=raspberry
device_type=1-0050F204-1
driver_param=use_p2p_group_interface=1
p2p_go_intent=1
p2p_go_ht40=1
then stop the wpa_supplicant and change
sudo wpa_supplicant -B -iwlan0 -Dnl80211 -c/etc/p2p.conf
i've started wpa_cli
and then p2p_find
it's started scanning
when i search from the smartphone for the raspberry, i found the raspberry, when i try to conenct it asks me for PIN code, the PIN code is showen in the raspberry wpa_cli.
two problem i have from this option:
1. the network needs to be connected.
2. the PIN code changes, and i can't make it fixed.
Is there a way to make an initial connection to setup a network from the smartphone to a headless raspberry?

Related

Openwrt/Raspberry: lost the connection after periodic connection test through usb wifi adapter

I'm developing a script that permits to connect to the internet through a Mediatek MT7612U wifi adapter (Alfa AWUS036ACM) and making some connection tests using speedtest-cli, iperf3 ...
My script is running under OpenWrt linux system. I installed Openwrt in a raspberry PI4 Model B. I plugged to the raspberry two wifi adapter (Alfa AWUS036ACM with Mediatek MT7612U chipset).
The script is running permenantly, and making periodically some connection Tests. After a period of time I lost the connection.
When I checked the system log I found this error reported by the kernel:
kern.err kernel: [ 1929.020945] mt76x2u 2-1:1.0: error: mt76x02u_mcu_wait_resp failed with -110
The issue disappear when I reboot the system. But I need to fix it without rebooting.
I tried to reset the usb device with ioctl USBDEVFS_RESET but that caused the lost of corresponding network interfaces,
I tried also to poweroff/poweron the usb device with commands like that:
echo disabled > /sys/bus/usb/devices/usb2/power/wakeup
echo enabled > /sys/bus/usb/devices/usb2/power/wakeup
but the issue is not fixed
I tried also to unbind/bind the usb device
echo '2-1' > /sys/bus/usb/drivers/usb/unbind
echo '2-1' > /sys/bus/usb/drivers/usb/bind
and the issue is not fixed also
Has someone an idea why I got this blocker issue. Is there an idea to fix or bypass it without the need to reboot the system.
I've also been getting this exact issue. I've also been using the Alfa AWUS036ACM.
I've tried unplugging the adapter and that resets it, then after putting it into monitor mode again it works for a short while before failing with the issue OP has again. I'm using a Raspberry Pi 3b

From WiFi to Cellular 3/4G on ESP32

I am building a project utilizing Wifi on the ESP32 module. Using RTOS, I am running a web server on 1 core and a web client on another core. This works very well and I can access the web server remotely via my browser and the WiFi provided IP address. The Web client reads some sensors and sends the data via WiFi to my database. All good and everything works as desired.
Now I need to do the next step and move beyond the reach of the WiFi and reproduce the same result via 3/4G cellular. I looked at the "easy" solution to use an industrial 3/4G WiFi router and simply keep what I have. Cost of these "industrial" type routers are on the high side, where as 3/4G module which also include a GPS chip are around half or less. Problem is that I cannot get my head around how I will "replace" my current WiFi functionality with one of these modules. The modules seems to expect you to connect via serial (rs232) and using modem AT commands establish a connection to the internet. Question is, after connecting to the internet, how do you continue to have "network functionality" same as with the built-in WiFi? Is there some library that will do ethernet over the serial port? Can I still have the WiFi and the "serial ethernet" running at the same time or switch between the two?
Thanks!

Is there anyway to send data through RPi and the Mac OS X wirelessly?

I am trying to build a robot that captures images from the RPi camera that is in installed, and try to sent it over to my Mac to do the image recognition and sent the result back. The robot was controlled by the Raspberry Pi 3 Model B. I have tried to communicate through socket but the whenever the it tries to connect, it always says “Connection refused” Any suggestions on new ways to communicate the RPi and the Mac wirelessly?
This is the code for the Server:
import socket
server = socket.socket()
server.bind(('127.0.0.1', 8000))
server.listen(0)
connection = server.accept()[0].makefile('wb')
print("success")
This is the code for the Client:
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('127.0.0.1', 8000))
connection = client.makefile('rb')
print('connection sucessful')
Remember: I am just trying to make sure that the connection between the Raspberry Pi and the Mac is successful.
I just figure it out. I just noticed that before I even connect, I am already connected to the RPi using SSH. I was using this so I could edit the code of the RPi. So what I did is that I connected the RPi to a different device, and then run the server code on the Mac, and the client on the RPi. It was a success.
Sorry if you were having a hard time answering my question. After all, it was just a mistake noticing the SSH connection.

CAN bus turns to ERROR PASSIVE state when loopback is turned off

I have connected a PiCAN2 board with raspberry pi running latest Jessie. When I try to send some CAN messages to my PC ( PC is connected via a USB to DB9 CAN interface to the PiCAN2 board) through this PiCAN2 using the can-utils, it runs into ERROR-PASSIVE state as soon as I bring the CAN interface up. But, when I enable loopback mode, I am able to send messages and receive them using two different terminal window on the raspberry pi itself. I enabled loopback mode using
sudo /sbin/ip link set can0 type can bitrate 500000 loopback on.
Can some one tell me more about the loopback mode? I want to make sure that my hardware setup for PiCAN2 is correct. Is it possible to confirm that my CAN board is configured correctly because I can send/receive messages using loopback mode?Or this doesn't necessarily mean that it is correct?
I also want to know why I get the ERROR PASSIVE mode - does it indicate that the PiCAN2 is not configured correctly OR does it mean that my USB to DB9 CAN interface has some problem? I am new to this area and any help would be nice. Thank you.

Open a socket connection to bluetooth device without a virtual COM port

I am using the 32feet bluetooth library to connect to a device that supports Serial Port Profile (SPP). I try to connect like this:
using (BluetoothClient client = new BluetoothClient())
{
var address = new BluetoothAddress(0xecfe7e11c3af);
BluetoothEndPoint endPoint = new BluetoothEndPoint(address, BluetoothService.SerialPort);
client.Connect(endPoint);
var stream = client.GetStream();
System.Threading.Thread.Sleep(10000);
}
Everything is great until the Connect method is called. At this point, Windows interrupts the program flow with a bubble alert that says
"A bluetooth device is trying to connect -- click to allow this"
At which point the user is led through a wizard that ends up installing drivers and a Bluetooth virtual COM port shows up in Device Manager. I don't want this to happen -- I want to simply access the stream and communicate directly with the device without windows intervening. Is this possible? What can be done to tell Windows to keep out of my business?
I'm attempting to connect to a Bluetooth 4.0 device. I've done something similar in the past with a 2.0 device and Windows does not interfere in this case.
Have a look at http://SimpleBluetooth4Win.SourceForge.net
It's a small wrapper library that uses the windows bluetooth networking API that could help you.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa362932%28v=vs.85%29.aspx
In particular if your bluetooth USB dongle or bluetooth device has been correctly recognized by the appropriate drivers and the remote bluetooth device is already paired with the PC, you don't need to install a bluetooth virtual COM port that shows up in Device Manager but you simply use the write or read calls to access directly the stream for communicating with the paired device.

Resources