embeded/raspberry pi2020. 5. 15. 16:24

DHCP로 주소도 받아와서 핸드폰에서는 문제없이 되는줄 알았는데

노트북에서 해보니 ssh는 permission denied가 뜨고, nginx로 띄워둔 홈페이지는 접근이 되지 않는다.

 

도대체 핸드폰에서는 어떻게 되었던 거지?

 

+ 2020.05.16

다시 정신 차리고 해보니 자기 자신 아이피를 넣고 있으니 안되지 -_-

문제없이 잘된다.

+

 

그리고 hw_mode=g로 설정을 해놔서 802.11n을 지원하는 녀석임에도 불구하고 54Mbps로만 잡힌다.

둘다 테스트를 추가로 해봐야 할 듯..

# ieee80211n: Whether IEEE 802.11n (HT) is enabled
# 0 = disabled (default)
# 1 = enabled
# Note: You will also need to enable WMM for full HT functionality.
# Note: hw_mode=g (2.4 GHz) and hw_mode=a (5 GHz) is used to specify the band.
#ieee80211n=1

# ht_capab: HT capabilities (list of flags)
# LDPC coding capability: [LDPC] = supported
# Supported channel width set: [HT40-] = both 20 MHz and 40 MHz with secondary
# channel below the primary channel; [HT40+] = both 20 MHz and 40 MHz
# with secondary channel above the primary channel
# (20 MHz only if neither is set)
# Note: There are limits on which channels can be used with HT40- and
# HT40+. Following table shows the channels that may be available for
# HT40- and HT40+ use per IEEE 802.11n Annex J:
# freq HT40- HT40+
# 2.4 GHz 5-13 1-7 (1-9 in Europe/Japan)
# 5 GHz 40,48,56,64 36,44,52,60
# (depending on the location, not all of these channels may be available
# for use)
# Please note that 40 MHz channels may switch their primary and secondary
# channels if needed or creation of 40 MHz channel maybe rejected based
# on overlapping BSSes. These changes are done automatically when hostapd
# is setting up the 40 MHz channel.
# HT-greenfield: [GF] (disabled if not set)
# Short GI for 20 MHz: [SHORT-GI-20] (disabled if not set)
# Short GI for 40 MHz: [SHORT-GI-40] (disabled if not set)
# Tx STBC: [TX-STBC] (disabled if not set)
# Rx STBC: [RX-STBC1] (one spatial stream), [RX-STBC12] (one or two spatial
# streams), or [RX-STBC123] (one, two, or three spatial streams); Rx STBC
# disabled if none of these set
# HT-delayed Block Ack: [DELAYED-BA] (disabled if not set)
# Maximum A-MSDU length: [MAX-AMSDU-7935] for 7935 octets (3839 octets if not
# set)
# DSSS/CCK Mode in 40 MHz: [DSSS_CCK-40] = allowed (not allowed if not set)
# 40 MHz intolerant [40-INTOLERANT] (not advertised if not set)
# L-SIG TXOP protection support: [LSIG-TXOP-PROT] (disabled if not set)
#ht_capab=[HT40-][SHORT-GI-20][SHORT-GI-40]

[링크 : https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf]

[링크 : https://airpage.org/xe/project_data/24937]

'embeded > raspberry pi' 카테고리의 다른 글

rpi / android h264 streaming  (0) 2020.05.24
hostapd 802.11n 설정하기 시도중  (0) 2020.05.16
RC카 node.js was 제작 1차 완료  (0) 2020.05.14
node.js raspi-pwm  (0) 2020.05.14
node.js onoff  (0) 2020.05.13
Posted by 구차니
embeded/raspberry pi2020. 5. 14. 19:18

일단은 대충 예전 기억 되살려서 대충대충 만들었음

 

 

 

무선랜 카드가 하나뿐인걸 라즈베리에 해놔서 PC에서 테스트할 방법이 현재는 없어서

다이소에서 하나 사던가 해야 할 듯 -_ㅠ

 

ip:3000/api/f

ip:3000/api/r

ip:3000/api/s

 

ip:3000/api/wl

ip:3000/api/ws

ip:3000/api/wr

 

으로 명령을 주도록 했고 PWM은 100%로 설정함

코드 복사하기에는 여러개라 귀찮으니 github를 이용하는 걸로 결정

 

이제.. 안드로이드 앱 만들면 되는건가...

 

[링크 : https://github.com/minimonk82/rpi_nodejs_rc/]

'embeded > raspberry pi' 카테고리의 다른 글

hostapd 802.11n 설정하기 시도중  (0) 2020.05.16
hostapd 통신이 안되네? -> 되네!  (0) 2020.05.15
node.js raspi-pwm  (0) 2020.05.14
node.js onoff  (0) 2020.05.13
라즈베리 파이 무선공유기 만들기(비밀번호 없이)  (0) 2020.05.13
Posted by 구차니
embeded/raspberry pi2020. 5. 14. 10:20

일단 코드가 작동하는건 확인

얘는 핀헤더 번호 - 핀 번호 식으로 붙게 되어있어서 오히려 더 편하다고 해야하려나?

 

const raspi = require('raspi');
const pwm = require('raspi-pwm');
const Gpio = require('onoff').Gpio;

raspi.init(() => {
  const led = new pwm.PWM('P1-33');
  led.write(0.3); // 50% Duty Cycle, aka half brightness
});

var in1 = new Gpio(5, 'out')
var in2 = new Gpio(6, 'out')

in1.writeSync(1)
in2.writeSync(0)

 

[링크 : https://www.npmjs.com/package/raspi-pwm]

'embeded > raspberry pi' 카테고리의 다른 글

hostapd 통신이 안되네? -> 되네!  (0) 2020.05.15
RC카 node.js was 제작 1차 완료  (0) 2020.05.14
node.js onoff  (0) 2020.05.13
라즈베리 파이 무선공유기 만들기(비밀번호 없이)  (0) 2020.05.13
dhcpcd 설정  (0) 2020.05.13
Posted by 구차니
embeded/raspberry pi2020. 5. 13. 21:50

wiringpi와는 다르게 BCM 쪽의 번호를 써야 하는 차이가 있다.

그리고 onoff 모듈은 pwm은 지원하지 않아서 다른걸 써야 할 듯..

 

아래는 gpio 유틸리티로 설정하는 부분 이고 아래의 포트는

// 초기설정
sudo gpio mode 21 out
sudo gpio mode 22 out
sudo gpio mode 23 pwm

 

node.js onoff 에서는 다음과 같이 다른 번호를 사용하게 된다.

const Gpio = require('onoff').Gpio;

var in1 = new Gpio(5, 'out')
var in2 = new Gpio(6, 'out')
var in0 = new Gpio(13, 'out')

in1.writeSync(1)
in2.writeSync(0)
in0.writeSync(1)

 

 

[링크 : https://www.npmjs.com/package/onoff]

 

 

PWM 지원하는 녀석 이라는데 코드를 막상보면

PWM을 하드웨어로 구현하는게 아니라 타이머를 이용해서 소프트웨어 PWM으로 구현한 듯

const Gpio = require('pigpio').Gpio;
 
const led = new Gpio(17, {mode: Gpio.OUTPUT});
 
let dutyCycle = 0;
 
setInterval(() => {
  led.pwmWrite(dutyCycle);
 
  dutyCycle += 5;
  if (dutyCycle > 255) {
    dutyCycle = 0;
  }
}, 20);


[링크 : https://github.com/fivdi/pigpio]

Posted by 구차니
embeded/raspberry pi2020. 5. 13. 20:23

패키지 설치

$ sudo apt-get install hostapd dnsmasq

 

hostapd 설정

wpa_로 시작하는 것을 주석풀면 WPA-PSK로 암호 '1234567890' 을 사용 AP를 구동한다.

$ cat /etc/hostapd/hostapd.conf
interface=wlan0
hw_mode=g
channel=7
wmm_enabled=0
ignore_broadcast_ssid=0
ssid=NETWORK

macaddr_acl=0
auth_algs=1
#wpa=2
#wpa_passphrase=1234567890
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

 

dnsmasq 설정

dhcpcd 필요한줄 알았는데 dhcpcd 없이 바로 구동된다.

$ cat /etc/dnsmasq.conf

interface=wlan0 

  dhcp-range=192.168.0.11,192.168.0.30,255.255.255.0,24h

 

+

테스트용으로 nginx 설치하고, 핸드폰으로 해당 AP에 접속하고

크롬을 통해 192.168.0.10 으로 접속하니 ngnix 페이지가 정상적으로 뜬다.

$ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::a73b:b28c:e97:7810  prefixlen 64  scopeid 0x20<link>
        ether 4c:e6:76:90:50:d5  txqueuelen 1000  (Ethernet)
        RX packets 1014  bytes 151616 (148.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 931  bytes 152637 (149.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

'embeded > raspberry pi' 카테고리의 다른 글

node.js raspi-pwm  (0) 2020.05.14
node.js onoff  (0) 2020.05.13
dhcpcd 설정  (0) 2020.05.13
라즈베리 파이 iwlist, iwconfig 로 무선접속하기  (0) 2020.05.09
라즈베리 파이 wifi AP로 설정하기  (0) 2020.05.09
Posted by 구차니
embeded/raspberry pi2020. 5. 13. 18:51

결론만 말하자면

dhcpcd 만으로는 무선 공유기 처럼 만드는건 실패.

dnsmasq가 있어야 한다.

 

+

테스트 해보니 dhcpcd 없이 hostapd + dnsmasq 만으로 ap가 만들어진다.

 

--

 

dhcpcd 패키지 설치해주고

아래의 설정내용을 넣어주면 끝.

 

$ sudo apt-cache search dhcpcd
dhcpcd - DHCP client for automatically configuring IPv4 networking
$ sudo vi /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8

[링크 : https://wiki.archlinux.org/index.php/dhcpcd]

 

+

기본 설정시 DHCP 잡는 임의 영역 IP인 169.254.71.x로 잡히는데

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.71.187  netmask 255.255.0.0  broadcast 169.254.255.255

 

dhcpcd.conf의 static_ip_address를 169.254.71.0/24로 설정하니

아래와 같이 carrier lost 뜨면서 되지 않는다.

아마 DHCP 잡는 reserved ip 영역이라 그런게 아닐까 추측됨.

$ systemctl status dhcpcd
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: failed (Result: signal) since Wed 2020-05-13 18:23:15 KST; 5min ago
  Process: 1694 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 1696 (code=killed, signal=SEGV)

 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: carrier acquired
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: IAID 76:90:50:d5
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: adding address fe80::a73b:b28c:e97:7810
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: using static address 169.254.71.187/24
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: adding route to 169.254.71.0/24
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: carrier lost
 5월 13 18:23:14 raspberrypi dhcpcd[1696]: wlan0: deleting address fe80::a73b:b28c:e97:7810
 5월 13 18:23:15 raspberrypi dhcpcd[1696]: wlan0: deleting route to 169.254.71.0/24
 5월 13 18:23:15 raspberrypi systemd[1]: dhcpcd.service: Main process exited, code=killed, status=11/SEGV
 5월 13 18:23:15 raspberrypi systemd[1]: dhcpcd.service: Failed with result 'signal'.

 

$ dmesg
[  542.390642] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  542.423897] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[  542.451050] WARN::dwc_otg_hcd_urb_dequeue:639: Timed out waiting for FSM NP transfer to complete on 0
[  543.220943] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  543.922372] WARN::dwc_otg_hcd_urb_dequeue:639: Timed out waiting for FSM NP transfer to complete on 3

 

+

ip 주소를 가져오는 중에서 넘어가질 않네..

인증이 문제인가?

Posted by 구차니
embeded/raspberry pi2020. 5. 9. 22:53

라즈베리 파이 2B / debian 10.3 이미지 사용

buffalo WLI-UC-GNM 802.11n 어댑터 사용

 

 

무선랜 스캔

$ iwlist wlan0 scan

 

무선랜 설정 (무선랜 이름이 iptime 일 경우)

$ sudo iwconfig wlan0 essid "iptime"

 

WPA_PSK 키 설정 (iptime 공유기의 무선랜 암호가 password일 경우)

(단, root 계정으로 하지 않으면 wpa_passphrase 실행 결과를 복사해서 sudo로 conf 파일에 넣어야 함)

wpa_passphrase "iptime" password > /etc/wpa_supplicant/wpa_supplicant.conf

 

무선랜 접속

아래의 명령어가 실행중인 동안에만 유지가 된다.

sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

 

[링크 : https://lhjin.tistory.com/entry/리눅스에서-무선랜WiFi-사용방법]

[링크 : http://webterror.net/?p=783]

 

 

그럼 이제 이걸.. 기본 데몬으로 가능한 방법을 찾으면 되려나?

 

+

wpa_supllicant.conf 파일에 내용이 존재하면 자동으로 그걸 이용해서 접속하도록 되어있다.

reboot 이후 정상적으로 접속되는 것을 확인함

 

[링크 : https://weworkweplay.com/play/automatically-connect-a-raspberry-pi-to-a-wifi-network/]

'embeded > raspberry pi' 카테고리의 다른 글

라즈베리 파이 무선공유기 만들기(비밀번호 없이)  (0) 2020.05.13
dhcpcd 설정  (0) 2020.05.13
라즈베리 파이 wifi AP로 설정하기  (0) 2020.05.09
GND가 문제였군..  (0) 2020.05.05
라즈베리 + L298N 실패..  (0) 2020.04.30
Posted by 구차니
embeded/raspberry pi2020. 5. 9. 21:37

hostapd만 설치하고 open system 으로 설정하니

ip 주소를 받아오지 못해서 핸드폰에서 정상적으로 접속하지 못한다.

dnsmasq를 꼭 깔아야 하려나? dhcpcd만 깔면되려나..

 

----

 

hostapd / dnsmasq 두개가 debian 계열 패키지로 제공되는 녀석인 듯

드론 처럼 wifi AP로만 쓰고 외부로 접속을 공유해주는 '무선공유기'를 만들게 아니라면

dnsmasq는 쓸데 없을 것 같긴한데..

dnsmasq에 dhcpcd 가 포함이 되는거라면 hostapd / dhcpcd 두개를 설치하는 것이 내가 원하는 방향이 될 듯 하다.

 

$ sudo apt install hostapd

[링크 : https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/]

[링크 : https://airpage.org/xe/project_data/24937]

[링크 : https://fishpoint.tistory.com/2159]

 

+

$ systemctl status hostapd
● hostapd.service
   Loaded: masked (Reason: Unit hostapd.service is masked.)
   Active: failed (Result: exit-code) since Sat 2020-05-09 23:02:20 KST; 11min ago

 5월 09 23:02:20 raspberrypi systemd[1]: hostapd.service: Service RestartSec=100ms expired, scheduling restart.
 5월 09 23:02:20 raspberrypi systemd[1]: hostapd.service: Failed to schedule restart job: Unit hostapd.service is masked.
 5월 09 23:02:20 raspberrypi systemd[1]: hostapd.service: Failed with result 'exit-code'.

 

구동이 안되네?

$ sudo service hostapd restart
Failed to restart hostapd.service: Unit hostapd.service is masked.

 

masked는 첨 보는데.. 찾아보니 unmask 라는걸로 풀어주고 하면 문제가 없다.

$ sudo systemctl unmask hostapd
$ sudo systemctl enable hostapd
$ sudo systemctl start hostapd

 

아무튼.. 데몬을 실행하니 아래와 같이 아이피 하나 잡혀주긴 한다.

$ ifconfig wlan0
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 4c:e6:76:90:50:d5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.71.187  netmask 255.255.0.0  broadcast 169.254.255.255
        inet6 fe80::a73b:b28c:e97:7810  prefixlen 64  scopeid 0x20<link>
        ether 4c:e6:76:90:50:d5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 5854 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

핸드폰에서 확인하니 NETWORK 라는 무선 AP가 생겨났지만

PASSWORD라고 암호를 설정해준 것이 문제인지 인증 과정에서 넘어가질 못한다.

[링크 : https://www.diymaker.net/143]

 

+

wpa=0

auth_algs=1

위와 같이 하면 open system authentication으로 암호없이 접속은 가능해진다.

auth_algs=0 으로 하면 "no authentication algorithms allowed" 에러가 뜨며 데몬이 정상적으로 구동되지 않는다.

 

##### WPA/IEEE 802.11i configuration ##########################################

# Enable WPA. Setting this variable configures the AP to require WPA (either
# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either
# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.
# Instead of wpa_psk / wpa_passphrase, wpa_psk_radius might suffice.
# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),
# RADIUS authentication server must be configured, and WPA-EAP must be included
# in wpa_key_mgmt.
# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
# and/or WPA2 (full IEEE 802.11i/RSN):
# bit0 = WPA
# bit1 = IEEE 802.11i/RSN (WPA2) (dot11RSNAEnabled)
# Note that WPA3 is also configured with bit1 since it uses RSN just like WPA2.
# In other words, for WPA3, wpa=2 is used the configuration (and
# wpa_key_mgmt=SAE for WPA3-Personal instead of wpa_key_mgmt=WPA-PSK).
#wpa=2

# IEEE 802.11 specifies two authentication algorithms. hostapd can be
# configured to allow both of these or only one. Open system authentication
# should be used with IEEE 802.1X.
# Bit fields of allowed authentication algorithms:
# bit 0 = Open System Authentication
# bit 1 = Shared Key Authentication (requires WEP)
auth_algs=3

[링크 : https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf]

 

+ 2020.05.13

wpa=0 이 아니라 wpa 를 아예 설정하지 않으면 암호 없는 네트워크로 설정된다.

 

[링크 : http://nitlab.inf.uth.gr/mazi-guides/accessPoint.html]

'embeded > raspberry pi' 카테고리의 다른 글

dhcpcd 설정  (0) 2020.05.13
라즈베리 파이 iwlist, iwconfig 로 무선접속하기  (0) 2020.05.09
GND가 문제였군..  (0) 2020.05.05
라즈베리 + L298N 실패..  (0) 2020.04.30
라즈베리 파이 pinout 유틸리티  (0) 2020.04.30
Posted by 구차니
embeded/odroid2020. 5. 8. 17:23

i5-2500 / HD 7950 으로 돌려도 버벅대된 녀석이

odroid XU4 / ubuntu / kodi로 재생하니 아무런 문제없이 잘 돌아간다.

덕분에 지름신은 좀 물리쳐질지도?

 

삼성 홈페이지에서는 Exynos 5 Octa (5422) 스펙에 FHD 120fps 인코딩 / 디코딩이 가능하다는데

Full HD 120fps encoding and
decoding with VP8 Codec

[링크 : https://www.samsung.com/semiconductor/minisite/exynos/products/mobileprocessor/exynos-5-octa-5422/]

 

hardkernel 쪽 사용자 설명서에서는 된다고 하니 되는거 맞겠지 머..

[링크 : https://books.google.co.kr/books?id=-D9QCwAAQBAJ&pg=PA11&lpg=PA11&dq=Exynos5422+h265...]

'embeded > odroid' 카테고리의 다른 글

odroid c2  (0) 2021.08.22
모니터 소비전력과 오드로이드 XU4  (0) 2020.06.02
odroid xu4 ADC 2CH  (0) 2020.03.28
odroid xu4 image 테스트  (0) 2020.03.28
odroid xu4 vlc error  (0) 2020.03.27
Posted by 구차니
embeded/arduino(genuino)2020. 5. 5. 16:05

완전 동일한 보드 / 모터 관련 글 이 검색에 똭!

해보니 잘 돌아간다. 돌아가니.. 분석을 해봐야지..

[링크 : http://blog.naver.com/ubicomputing/220747940482]

 

+

생각을 해보니, 스텝모터는 펄스로 한 스텝씩 이동시키는 것일 뿐이니..

ULN2003은 단순하게 보면 4채널 on/off 가능한 칩으로 보면 될 지도 모르겠네?

 

H brigde가 없어서 전진/후진 바꾸어서 하진 못하고 on/off만 가능함.

[링크 : https://blog.danggun.net/2647]

 

+

 

delay() 안쓰고 micros() 함수로 us 단위 시간을 받아와 busy wait 하도록 구성되어있네..

1스텝에 1us, 4096 스텝에 한바퀴니 4초 움직이고 2초 쉬고 4초 반대로 움직이도록 코드가 되어있고

[링크 : https://www.arduino.cc/reference/en/language/functions/time/micros/]

 

속도를 느리게 해서 LED 불 들어오는 걸 보니

A / AB / B / BC / C / CD / D / DA 를 반복해서 모터를 구동하도록 되어있는 것으로 보인다.

 

'embeded > arduino(genuino)' 카테고리의 다른 글

TEA5767 살까 말까..  (0) 2020.06.15
지름신 축적중  (0) 2020.06.10
L298N 보드 사용 준비  (0) 2020.04.28
L293D 아두이노 드라이버  (0) 2020.04.22
라즈베리 - 아두이노 i2c 통신 예제  (0) 2020.04.18
Posted by 구차니