Skip to content
Commits on Source (21)
......@@ -14,12 +14,6 @@ config ARCH_HAVE_LEDS
config HN70AP_HWDEBUG_BLINK
bool "Just Blink leds instead of starting NuttX"
config HN70AP_EEPROM
bool "Enable EEPROM (requires I2C3)"
config HN70AP_SPIFLASH
bool "Enable SPI FLASH (requires SPI2)"
config HN70AP_SCREEN
bool "Enable OLED screen (requires I2C3)"
......
......@@ -5,7 +5,7 @@
config HN70AP_CONFIG
bool "system configuration app"
default y
default n
---help---
The config app manages the system settings.
......
......@@ -77,7 +77,7 @@ int config_list(void)
else if(type == EECONFIG_TYPE_IP)
{
struct in_addr val;
ret = hn70ap_eeconfig_getip(name, &val);
ret = hn70ap_eeconfig_getip(name, &val.s_addr);
if(ret == OK)
{
printf("%s\n", inet_ntoa(val));
......
......@@ -37,7 +37,7 @@
#define HN70AP_LCD_H
int hn70ap_lcd_init(void);
int hn70ap_lcd_drawchar(int row, int col, char *ch);
int hn70ap_lcd_drawchar(int row, int col, char ch);
int hn70ap_lcd_drawstr(int row, int col, char *ch);
#endif
......@@ -42,9 +42,11 @@
#define HN70AP_RADIO_MAIN 1
#define HN70AP_RADIO_AUX 2
typedef int (*radiorxfunction_f)(uint8_t device, FAR void *arg, FAR uint8_t *data, int length);
int hn70ap_radio_init(void);
int hn70ap_radio_transmit(uint8_t device, uint8_t *buf, size_t len);
int hn70ap_radio_receive (uint8_t device, uint8_t *buf, size_t len);
int hn70ap_radio_rxfunction(uint8_t device, radiorxfunction_f rx, FAR void *arg, FAR uint8_t *userbuf, int userbuflen);
int hn70ap_radio_transmit(uint8_t device, FAR uint8_t *buf, size_t len);
#endif /* HN70AP_SYSTEM_H */
/****************************************************************************
* hn70ap/apps/export/tun.h
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef HN70AP_TUN_H
#define HN70AP_TUN_H
#include <stdint.h>
#include <stdbool.h>
#include <netinet/in.h>
#include <net/if.h>
typedef int (*tunrxfunction_f)(uint8_t tun, FAR void *arg, FAR uint8_t *data, int length);
int hn70ap_tun_init(void);
int hn70ap_tun_devinit(char ifname[IFNAMSIZ]);
int hn70ap_tun_addroute(int tunnel, in_addr_t destination, int maskbits);
int hn70ap_tun_rxfunction(int tunnel, tunrxfunction_f rx, FAR void *arg, FAR uint8_t *userbuf, int userbuflen);
int hn70ap_tun_transmit(int tunnel, FAR uint8_t *buf, size_t len);
#endif /* HN70AP_SYSTEM_H */
......@@ -5,4 +5,4 @@
config LIBHN70AP
bool "Common Library"
default y
default n
......@@ -37,6 +37,11 @@
ASRCS =
CSRCS = eeprom.c leds.c lcd.c timer.c system.c radio.c
ifeq ($(CONFIG_NET_TUN),y)
CSRCS += tun.c
endif
CSRCS += tlv.c crc.c sha256.c hdlc.c
CSRCS += update.c
......
......@@ -33,6 +33,19 @@
*
****************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <nuttx/video/fb.h>
#include <nuttx/nx/nxglib.h>
#include <hn70ap/lcd.h>
//Manage the 128x64 LCD
//Using aligned character positions, we can write 8 lines of 16 chars
......@@ -304,8 +317,87 @@ unsigned char font[2048] =
* hn70ap_lcd_init
****************************************************************************/
struct fb_state_s
{
int fd;
struct fb_videoinfo_s vinfo;
struct fb_planeinfo_s pinfo;
FAR void *fbmem;
};
struct fb_state_s state;
int hn70ap_lcd_init(void)
{
int ret;
state.fd = open("/dev/fb0", O_RDWR);
if (state.fd < 0)
{
int errcode = errno;
fprintf(stderr, "ERROR: Failed to open /dev/fb0: %d\n", errcode);
return EXIT_FAILURE;
}
ret = ioctl(state.fd, FBIOGET_VIDEOINFO,
(unsigned long)((uintptr_t)&state.vinfo));
if (ret < 0)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIOGET_VIDEOINFO) failed: %d\n",
errcode);
close(state.fd);
return EXIT_FAILURE;
}
ret = ioctl(state.fd, FBIOGET_PLANEINFO,
(unsigned long)((uintptr_t)&state.pinfo));
if (ret < 0)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
errcode);
close(state.fd);
return EXIT_FAILURE;
}
if (state.pinfo.bpp != 1)
{
fprintf(stderr, "ERROR: bpp=%u not supported\n", state.pinfo.bpp);
close(state.fd);
return EXIT_FAILURE;
}
state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FILE, state.fd, 0);
if (state.fbmem == MAP_FAILED)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n",
errcode);
close(state.fd);
return EXIT_FAILURE;
}
hn70ap_lcd_drawstr(0,0,"hn70ap!\r");
return 0;
}
/****************************************************************************
* hn70ap_lcd_drawchar
****************************************************************************/
static int hn70ap_lcd_drawchar_internal(int row, int col, char ch)
{
int i;
uint8_t *ptr = state.fbmem + (8 * row * state.pinfo.stride) + col;
for(i=0;i<8;i++)
{
*ptr = font [ch * 8 + i];
ptr += state.pinfo.stride;
}
return 0;
}
......@@ -315,6 +407,24 @@ int hn70ap_lcd_init(void)
int hn70ap_lcd_drawchar(int row, int col, char ch)
{
struct nxgl_rect_s rect;
int ret = hn70ap_lcd_drawchar_internal(row,col,ch);
#ifdef CONFIG_LCD_UPDATE
rect.pt1.x = col*8;
rect.pt1.y = row*8;
rect.pt2.x = rect.pt1.x + 8;
rect.pt2.y = rect.pt1.y + 8;
ret = ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect));
if (ret < 0)
{
int errcode = errno;
fprintf(stderr, "ERROR: ioctl(FBIO_UPDATE) failed: %d\n",
errcode);
}
#endif
return 0;
}
......@@ -324,9 +434,41 @@ int hn70ap_lcd_drawchar(int row, int col, char ch)
int hn70ap_lcd_drawstr(int row, int col, char *ch)
{
struct nxgl_rect_s rect;
int ret;
int cr = row;
int cc = col;
while(*ch)
{
if(*ch == '\r')
{
#ifdef CONFIG_LCD_UPDATE
rect.pt1.x = col*8;
rect.pt1.y = cr*8;
rect.pt2.x = (cc*8) + 8;
rect.pt2.y = rect.pt1.y + 8;
ret = ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect));
if (ret < 0)
{
fprintf(stderr, "ERROR: ioctl(FBIO_UPDATE) failed: %d\n", errno);
}
#endif
cc = col;
}
else if(*ch == '\n')
{
cr += 1;
}
else
{
hn70ap_lcd_drawchar_internal(cr,cc,*ch);
cc += 1;
}
ch++;
}
return 0;
}
......@@ -41,32 +41,49 @@
#include <fcntl.h>
#include <syslog.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <hn70ap/radio.h>
#include <hn70ap/leds.h>
static int g_hn70ap_fdmainradio;
static int g_hn70ap_fdauxradio;
/* management variables for one radio */
struct radio_s
{
int devfd;
bool alive;
pthread_t rxthread;
/*data reception and calling back to the user*/
FAR uint8_t * userbuf;
int userbuflen;
radiorxfunction_f callback;
FAR void * arg;
};
static bool g_hn70ap_radioalive;
static pthread_t g_hn70ap_txthreadid;
static struct radio_s g_hn70ap_mainradio;
static struct radio_s g_hn70ap_auxradio;
/****************************************************************************
* hn70ap_radio_txthread
* This thread waits for radio transmit requests from other processes,
* and sends packets.
* hn70ap_radio_receive
****************************************************************************/
void *hn70ap_radio_txthread(void *arg)
static int hn70ap_radio_receive(struct radio_s *radio, uint8_t *buf, size_t len)
{
syslog(LOG_INFO, "Started radio RX thread\n");
while(g_hn70ap_radioalive)
{
//Wait for messages in transmit queue
//Transmit these messages
}
syslog(LOG_INFO, "Stopped radio RX thread\n");
int ret;
/* Turn on radio LED in receive mode */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_ON);
/* Receive */
ret = read(radio->devfd, buf, len);
/* Turn off radio LED */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_OFF);
return ret;
}
/****************************************************************************
......@@ -75,16 +92,16 @@ void *hn70ap_radio_txthread(void *arg)
int hn70ap_radio_transmit(uint8_t device, uint8_t *buf, size_t len)
{
int fd;
struct radio_s *radio;
int ret;
if(device == HN70AP_RADIO_MAIN)
{
fd = g_hn70ap_fdmainradio;
radio = &g_hn70ap_mainradio;
}
else if(device == HN70AP_RADIO_AUX)
{
fd = g_hn70ap_fdauxradio;
radio = &g_hn70ap_auxradio;
}
else
{
......@@ -96,7 +113,7 @@ int hn70ap_radio_transmit(uint8_t device, uint8_t *buf, size_t len)
hn70ap_leds_state(LED_1B, LED_STATE_OFF);
/* Transmit */
ret = write(fd, buf, len);
ret = write(radio->devfd, buf, len);
/* Turn off radio LED */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
......@@ -106,78 +123,114 @@ int hn70ap_radio_transmit(uint8_t device, uint8_t *buf, size_t len)
}
/****************************************************************************
* hn70ap_radio_receive
* hn70ap_radio_rxthread
* This thread waits for radio packets on the air, and sends them to processes.
****************************************************************************/
int hn70ap_radio_receive(uint8_t device, uint8_t *buf, size_t len)
void *hn70ap_radio_rxthread(void *arg)
{
int fd;
struct radio_s *radio = (struct radio_s*)arg;
syslog(LOG_INFO, "Started radio RX thread\n");
int ret;
if(device == HN70AP_RADIO_MAIN)
while(radio->alive)
{
fd = g_hn70ap_fdmainradio;
if(radio->callback)
{
//Wait for messages on the air
ret = hn70ap_radio_receive(radio, radio->userbuf, radio->userbuflen);
if(ret > 0)
{
//Dispatch them to the callback
radio->callback((radio==&g_hn70ap_mainradio)?HN70AP_RADIO_MAIN:HN70AP_RADIO_AUX, radio->arg, radio->userbuf, ret);
}
else if(device == HN70AP_RADIO_AUX)
else
{
fd = g_hn70ap_fdauxradio;
//syslog(LOG_ERR, "radio rx failed -> errno=%d\n", errno);
}
} //callback defined
else
{
return ERROR;
pthread_yield();
}
} //radio alive
syslog(LOG_INFO, "Stopped radio RX thread\n");
return NULL;
}
/* Turn on radio LED in transmit mode */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_ON);
/****************************************************************************
* hn70ap_radio_devinit
****************************************************************************/
/* Transmit */
ret = read(fd, buf, len);
int hn70ap_radio_devinit(struct radio_s *radio, const char *dev)
{
int ret = 0;
/* Turn off radio LED */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_OFF);
radio->devfd = open(dev, O_RDWR);
if(radio->devfd<0)
{
syslog(LOG_ERR, "Failed to access main radio!\n");
ret = -1;
goto lret;
}
radio->callback = NULL;
radio->alive = true;
ret = pthread_create(&radio->rxthread, NULL, hn70ap_radio_rxthread, radio);
if(ret < 0)
{
syslog(LOG_ERR, "Failed to start the receive thread\n");
}
lret:
return ret;
}
/****************************************************************************
* hn70ap_radio_rxfunction
****************************************************************************/
int hn70ap_radio_rxfunction(uint8_t device, radiorxfunction_f rx, FAR void *arg, FAR uint8_t *userbuf, int userbuflen)
{
struct radio_s *radio;
if(device == HN70AP_RADIO_MAIN)
{
radio = &g_hn70ap_mainradio;
}
else if(device == HN70AP_RADIO_AUX)
{
radio = &g_hn70ap_auxradio;
}
else
{
return ERROR;
}
radio->userbuf = userbuf;
radio->userbuflen = userbuflen;
radio->arg = arg;
radio->callback = rx;
return OK;
}
/****************************************************************************
* hn70ap_radio_init
****************************************************************************/
int hn70ap_radio_init(void)
{
int ret = 0;
#ifdef CONFIG_HN70AP_MAINRADIO
syslog(LOG_INFO, "Checking main radio\n");
g_hn70ap_fdmainradio = open("/dev/rmain", O_RDWR);
if(g_hn70ap_fdmainradio<0)
{
syslog(LOG_ERR, "Failed to access main radio!\n");
ret = -1;
goto lret;
}
hn70ap_radio_devinit(&g_hn70ap_mainradio, "/dev/rmain");
#endif
#ifdef CONFIG_HN70AP_AUXRADIO
syslog(LOG_INFO, "Checking aux radio\n");
g_hn70ap_fdauxradio = open("/dev/raux", O_RDWR);
if(g_hn70ap_fdauxradio<0)
{
syslog(LOG_ERR, "Failed to access aux radio!\n");
ret = -1;
goto lret;
}
hn70ap_radio_devinit(&g_hn70ap_auxradio, "/dev/raux");
#endif
g_hn70ap_radioalive = true;
ret = pthread_create(&g_hn70ap_txthreadid, NULL, hn70ap_radio_txthread, NULL);
if(ret < 0)
{
syslog(LOG_ERR, "Failed to start the transmit thread\n");
}
lret:
return ret;
return OK;
}
......@@ -37,20 +37,27 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <syslog.h>
#include <net/if.h>
#include <hn70ap/eeprom.h>
#include <hn70ap/timer.h>
#include <hn70ap/leds.h>
#include <hn70ap/lcd.h>
#include <hn70ap/radio.h>
#include <hn70ap/tun.h>
static bool hn70ap_system_initialized = false;
int hn70ap_system_init(void)
{
int ret;
int tunid = -1;
bool defaults;
char tunname[IFNAMSIZ];
if(hn70ap_system_initialized)
{
......@@ -90,13 +97,36 @@ int hn70ap_system_init(void)
syslog(LOG_ERR, "WARNING: Default config values loaded in EEPROM\n");
}
ret = hn70ap_lcd_init();
if(ret != OK)
{
syslog(LOG_ERR, "WARNING: Failed to initialize Screen\n");
}
#ifdef CONFIG_NET_TUN
ret = hn70ap_tun_init();
if(ret != 0)
{
syslog(LOG_ERR, "WARNING: Failed to initialize tunnels\n");
}
strncpy(tunname, "uhf0", IFNAMSIZ);
ret = hn70ap_tun_devinit(tunname);
if(ret < 0)
{
syslog(LOG_ERR, "WARNING: Failed to initialize TUN interface\n");
}
tunid = ret;
#endif
ret = hn70ap_radio_init();
if(ret != 0)
{
syslog(LOG_ERR, "FATAL: Failed to initialize Radios\n");
return ERROR;
syslog(LOG_ERR, "WARNING: Failed to initialize Radios\n");
}
// bind the tunnel and the aux radio
hn70ap_system_initialized = true;
return OK;
......
/****************************************************************************
* hn70ap/apps/libhn70ap/tun.c
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include <nuttx/net/tun.h>
#include <hn70ap/tun.h>
struct iptunnel_s
{
int fd;
char ifname[IFNAMSIZ];
bool alive;
pthread_t rxthread;
/*data reception and calling back to the user*/
FAR uint8_t * userbuf;
int userbuflen;
tunrxfunction_f callback;
FAR void * arg;
};
struct iptunnel_s tunnels[2];
/****************************************************************************
* hn70ap_tun_rxthread
* This thread waits for packets from the tun interface, and sends them to processes.
****************************************************************************/
void *hn70ap_tun_rxthread(void *arg)
{
struct iptunnel_s *tunnel = (struct iptunnel_s*)arg;
syslog(LOG_INFO, "Started tun RX thread\n");
int ret;
while(tunnel->alive)
{
if(tunnel->callback)
{
//Wait for messages on the air
ret = read(tunnel->fd, tunnel->userbuf, tunnel->userbuflen);
if(ret > 0)
{
//Dispatch them to the callback
tunnel->callback((tunnel==tunnels)?0:1, tunnel->arg, tunnel->userbuf, ret);
}
else
{
//syslog(LOG_ERR, "tunnel rx failed -> errno=%d\n", errno);
}
} //callback defined
else
{
pthread_yield();
}
} //tunnel alive
syslog(LOG_INFO, "Stopped tunnel RX thread\n");
return NULL;
}
/****************************************************************************
* hn70ap_tun_transmit
****************************************************************************/
int hn70ap_tun_transmit(int tunnel, FAR uint8_t *buf, size_t len)
{
if(tunnel != 0 && tunnel != 1)
{
return -1;
}
return write(tunnels[tunnel].fd, buf, len);
}
/****************************************************************************
* hn70ap_tun_rxfunction
****************************************************************************/
int hn70ap_tun_rxfunction(int tunnel, tunrxfunction_f rx, FAR void *arg, FAR uint8_t *userbuf, int userbuflen)
{
if(tunnel != 0 && tunnel != 1)
{
return -1;
}
tunnels[tunnel].userbuf = userbuf;
tunnels[tunnel].userbuflen = userbuflen;
tunnels[tunnel].arg = arg;
tunnels[tunnel].callback = rx;
return OK;
}
/****************************************************************************
* hn70ap_tun_devinit
****************************************************************************/
int hn70ap_tun_devinit(char name[IFNAMSIZ])
{
struct ifreq ifr;
int errcode;
int fd;
int ret;
struct iptunnel_s *tunnel = &tunnels[0];
if(tunnel->fd != 0)
{
tunnel = &tunnels[1];
}
if(tunnel->fd != 0)
{
syslog(LOG_ERR, "No tunnel available");
return -1;
}
if ((fd = open("/dev/tun", O_RDWR)) < 0)
{
return fd;
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN;
if (name[0])
{
strncpy(ifr.ifr_name, name, IFNAMSIZ);
}
errcode = ioctl(fd, TUNSETIFF, (unsigned long)&ifr);
if(errcode < 0)
{
close(fd);
return errcode;
}
tunnel->fd = fd;
strncpy(tunnel->ifname, ifr.ifr_name, IFNAMSIZ);
syslog(LOG_INFO, "Started interface: %s\n", tunnel->ifname);
//Start RX thread
tunnel->alive = true;
tunnel->callback = NULL;
ret = pthread_create(&tunnel->rxthread, NULL, hn70ap_tun_rxthread, tunnel);
if(ret < 0)
{
syslog(LOG_ERR, "Failed to start the receive thread\n");
}
return fd;
}
/****************************************************************************
* hn70ap_tun_addroute
****************************************************************************/
int hn70ap_tun_addroute(int tunnel, in_addr_t destination, int maskbits)
{
return ERROR;
}
/****************************************************************************
* hn70ap_tun_init
****************************************************************************/
int hn70ap_tun_init(void)
{
tunnels[0].fd = 0;
tunnels[1].fd = 0;
return 0;
}
......@@ -5,7 +5,7 @@
config HN70AP_RXT
bool "RX test"
default y
default n
---help---
Test Radio Reception.
......
......@@ -55,8 +55,22 @@
* Public Functions
****************************************************************************/
/****************************************************************************
* status_main
* rxt_callback
****************************************************************************/
int rxt_callback(uint8_t device, FAR void *arg, FAR uint8_t *data, int length)
{
int i;
for(i=0; i<length; i++)
{
printf("%c", (data[i]<0x20 && data[i]!=0x0a)?'.':data[i]);
}
return 0;
}
/****************************************************************************
* rxt_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
......@@ -66,9 +80,7 @@ int rxt_main(int argc, char *argv[])
#endif
{
int ret = OK;
int fd;
int buflen = 1024;
int i;
uint8_t *buf;
......@@ -84,32 +96,13 @@ int rxt_main(int argc, char *argv[])
goto done;
}
do
{
ret = hn70ap_radio_receive(HN70AP_RADIO_AUX, buf, buflen);
//printf("read done, ret = %d, errno=%d\n", ret, errno);
if(ret > 0)
{
/* for(i=0; i<ret; i++)
{
printf("%02X ", buf[i]);
}
printf("\n");*/
for(i=0; i<ret; i++)
{
printf("%c", (buf[i]<0x20 && buf[i]!=0x0a)?'.':buf[i]);
}
}
else if(ret < 0 && errno==ETIMEDOUT)
{
printf("RX timeout\n");
// ret = 1;
// continue;
}
}
while(ret > 0);
hn70ap_radio_rxfunction(HN70AP_RADIO_AUX, rxt_callback, NULL, buf, buflen);
printf("type return to quit\n");
getchar();
printf("Read sequence done.\n");
printf("Stopping reception\n");
hn70ap_radio_rxfunction(HN70AP_RADIO_AUX, NULL, NULL, NULL, 0);
free(buf);
done:
......
......@@ -5,7 +5,7 @@
config HN70AP_SYSDAEMON
bool "system daemon"
default y
default n
---help---
The system daemon manages the ethernet link status, the oled screen, then starts nsh.
......
......@@ -47,6 +47,8 @@
#include <hn70ap/system.h>
#include <hn70ap/leds.h>
#include <hn70ap/eeprom.h>
#include <hn70ap/lcd.h>
#include <hn70ap/radio.h>
#include "sysdaemon_internal.h"
......@@ -72,10 +74,33 @@ void hn70ap_mount_storage(void)
printf("Mass Storage mounted at /data\n");
}
#endif
#ifdef CONFIG_FS_PROCFS
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
fprintf(stderr, "Failed to mount /proc\n");
}
else
{
printf("Mounted /proc\n");
}
#endif
}
/****************************************************************************
* status_main
* sysdaemon_radiocallback
****************************************************************************/
uint8_t radiobuf[512];
int sysdaemon_radiocallback(uint8_t device, FAR void *arg, FAR uint8_t *data, int length)
{
printf("RADIORX len %d\n", length);
return OK;
}
/****************************************************************************
* sysdaemon_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
......@@ -110,11 +135,14 @@ int sysdaemon_main(int argc, char *argv[])
printf("Hello %s, best 73's\n", call);
}
printf("TODO start screen management\n");
/* Try to open radio devices. */
ret = hn70ap_radio_rxfunction(HN70AP_RADIO_AUX, sysdaemon_radiocallback, NULL, radiobuf, sizeof(radiobuf));
if(ret == 0)
{
printf("aux radio cb installed ok\n");
}
#if defined(CONFIG_EXAMPLES_NSH)
#if defined(CONFIG_SYSTEM_NSH)
printf("*** Launching nsh\n");
nsh_main(argc, argv);
#endif
......
......@@ -192,6 +192,7 @@ static void* netmonitor_thread(void *arg)
struct timespec reltime;
struct ifreq ifr;
struct sigaction act;
struct sigaction oact;
bool devup;
int ret;
int sd;
......@@ -221,7 +222,7 @@ static void* netmonitor_thread(void *arg)
act.sa_sigaction = netmonitor_signal;
act.sa_flags = SA_SIGINFO;
ret = sigaction(SIGUSR2, &act, NULL);
ret = sigaction(SIGUSR2, &act, &oact);
if (ret < 0)
{
ret = -errno;
......@@ -394,7 +395,7 @@ static void* netmonitor_thread(void *arg)
errout_with_notification:
# warning Missing logic
errout_with_sigaction:
# warning Missing logic
(void)sigaction(SIGUSR2, &oact, NULL);
errout_with_socket:
close(sd);
errout:
......
......@@ -5,7 +5,7 @@
config HN70AP_TXT
bool "TX test"
default y
default n
---help---
Test Radio Transmission.
......
This diff is collapsed.
......@@ -702,8 +702,6 @@ CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y
# ----- hn70ap board features -----
#
# CONFIG_HN70AP_HWDEBUG_BLINK is not set
CONFIG_HN70AP_EEPROM=y
CONFIG_HN70AP_SPIFLASH=y
# CONFIG_HN70AP_SCREEN is not set
# CONFIG_HN70AP_ETHERNET is not set
CONFIG_HN70AP_RADIO=y
......