Sunday, August 28, 2022

How To Make Raspberry as Hotspot or Sink Controller

Install first for hostapd, dnsmasq with apt-get install

 please make prepare about several file for editing:

root@pi:/home/pi# nano /etc/dnsmasq.conf

keep it blank

root@pi:/home/pi# nano /etc/hostapd/hostapd.conf

country_code=ID
interface=wlan0
driver=nl80211
bridge=br0
#RADIUS
macaddr_acl=0
eap_server=0
own_ip_addr=192.168.2.1
radius_client_addr=192.168.2.2
auth_server_addr=192.168.2.1
auth_server_port=1812
auth_server_shared_secret=10041987nm
#hs20=1
hw_mode=g
channel=6
ieee8021x=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
ignore_broadcast_ssid=0
ssid=iCAL-Hotspot
auth_algs=1
#if you want to make password, uncomment below
#wpa=2
#wpa_key_mgmt=WPA-PSK
#rsn_pairwise=CCMP
#wpa_passphrase=haikalmiska

root@pi:/home/pi# nano /etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:

interface eth0
inform 192.168.2.2/24

interface wlan0
inform 192.168.2.3/24

#denyinterfaces eth0 wlan0


root@pi:/home/pi# nano /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# if there no an action, uncomment line below as trigger to IP Address
#auto br0
#auto eth0
#iface br0 inet static
#address 192.168.2.2/24
#gateway 192.168.2.1
#bridge_ports eth0 wlan0

__________________________________________________

root@pi:/home/pi# systemctl daemon-reload

root@pi:/home/pi# service networking restart

root@pi:/home/pi# service dhcpcd restart

root@pi:/home/pi# service hostapd start

root@pi:/home/pi# service dnsmasq start

any error have resolved with see the comments of error!


if you want to reset this hotspot to wifi client. The best way to (permanently) disable these services:

sudo update-rc.d hostapd disable

sudo update-rc.d dnsmasq disable

- reboot

Sunday, August 21, 2022

Resolve mail configuration Postfix on Centos

At upon time, I want to access mail with php mail, and any error on it (PHP Native and CodeIgniter, so Laravel). So I try many tutorials and I get any keyword since send mail on centos:

Null message body; hope that's ok
postdrop: warning: mail_queue_enter: create file maildrop/71281.94914: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/71596.94914: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/72031.94914: Permission denied
postdrop: warning: mail_queue_enter: create file maildrop/72835.94914: Permission denied


the best way to resolve it:

[root@.......]# postfix set-permissions
[root@.......]# mail -s "Hello World" admin@webiot.id

Null message body; hope that's ok
[root@.......]#

All php setting and send mail clear.

probably, this error comes after giving access or chmod. 



Sunday, June 19, 2022

Resolve OPENCV PYTHON Problem for your Environment Project

Several opencv problem and the resolve:

_____

- Problem:

on centos
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

- Resolve: 

yum install mesa-libGL

_____

- Problem:

cannot start Anaconda environment in windows

- Resolve: 

C:\Users\webiot>D:/Anaconda/Scripts/activate

_____

- Problem:

cv2.error: OpenCV(3.4.17) D:\a....\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:383: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

- Resolve: 

camera=cv2.VideoCapture(0) #check for input device, maybe 0 or 1 etc.

_____

- Problem:

recognizer = cv2.face.LBPHFaceRecognizer_create(); #create a recognizer, LBPH is a face recognition algorithm.Local Binary Patterns Histograms
AttributeError: module 'cv2' has no attribute 'face'

- Resolve: 

pip uninstall opencv-contrib-python

and install again:

pip install opencv-contrib-python

_____

- Problem:

faces=detector.detectMultiScale(frame,1.1,7)

cv2.error: OpenCV(3.4.17) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1729: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale'

- Resolve: 

run python as your path in the code

_____

- Problem:

sqlite3.OperationalError: no such column: 

- Resolve: 

check your parameter and add the value with single Quote each.

_____

- Problem:

sqlite3.OperationalError: database is locked

- Resolve: 

close all opened db browser

_____

- Problem:

CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638

- Resolve: 

downgrade your opencv-python with:

(base) C:\Users\webiot>pip uninstall opencv-python

(base) C:\Users\webiot>pip install opencv-python==3.4.17.63

(base) C:\Users\webiot>pip install opencv-contrib-python==3.4.17.63

_____


ANATHOR PROBLEM IN PYTHON

- Problem:

ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package

- Resolve: 

if you have install the mysql connector by: pip install mysql-connector-python

You make sure or rename your py file not as mysql.py

_____

- Problem:

Redirect has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header

- Resolve: 

Add this extension on chrome browser:

Allow CORS: Access-Control-Allow-Origin

_____

- Problem:

python flask not reading image from ajax POST request form

- Resolve: 

make sure that params use encodeURIComponent(uri):

ex:

client side

var tes = canvas.toDataURL("image/jpeg");

params = "baseku="+encodeURIComponent(tes);

xmlhttp.send(params);

server side

@app.route('/img', methods=['POST'])

def img():

    if 'baseku' in request.form:

        photo_base64 = request.form['baseku']

        return jsonify(response=photo_base64)

_____