...
 
Commits (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,39 +123,95 @@ 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;
while(radio->alive)
{
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
{
//syslog(LOG_ERR, "radio rx failed -> errno=%d\n", errno);
}
} //callback defined
else
{
pthread_yield();
}
} //radio alive
syslog(LOG_INFO, "Stopped radio RX thread\n");
return NULL;
}
/****************************************************************************
* hn70ap_radio_devinit
****************************************************************************/
int hn70ap_radio_devinit(struct radio_s *radio, const char *dev)
{
int ret = 0;
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)
{
fd = g_hn70ap_fdmainradio;
radio = &g_hn70ap_mainradio;
}
else if(device == HN70AP_RADIO_AUX)
{
fd = g_hn70ap_fdauxradio;
radio = &g_hn70ap_auxradio;
}
else
{
return ERROR;
}
/* Turn on radio LED in transmit mode */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_ON);
/* Transmit */
ret = read(fd, buf, len);
/* Turn off radio LED */
hn70ap_leds_state(LED_1A, LED_STATE_OFF);
hn70ap_leds_state(LED_1B, LED_STATE_OFF);
radio->userbuf = userbuf;
radio->userbuflen = userbuflen;
radio->arg = arg;
radio->callback = rx;
return ret;
return OK;
}
/****************************************************************************
......@@ -147,37 +220,17 @@ int hn70ap_radio_receive(uint8_t device, uint8_t *buf, size_t len)
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
......
......@@ -735,8 +735,6 @@ CONFIG_ARCH_LEDS=y
# ----- hn70ap board features -----
#
# CONFIG_HN70AP_HWDEBUG_BLINK is not set
CONFIG_HN70AP_EEPROM=y
CONFIG_HN70AP_SPIFLASH=y
CONFIG_HN70AP_SCREEN=y
CONFIG_HN70AP_ETHERNET=y
CONFIG_HN70AP_ETHERNET_EEMAC=y
......
This diff is collapsed.
......@@ -143,6 +143,7 @@ CONFIG_ARCH="arm"
CONFIG_ARCH_CHIP_STM32=y
# CONFIG_ARCH_CHIP_STM32F0 is not set
# CONFIG_ARCH_CHIP_STM32F7 is not set
# CONFIG_ARCH_CHIP_STM32H7 is not set
# CONFIG_ARCH_CHIP_STM32L4 is not set
# CONFIG_ARCH_CHIP_STR71X is not set
# CONFIG_ARCH_CHIP_TMS570 is not set
......@@ -172,8 +173,7 @@ CONFIG_ARCH_CORTEXM4=y
CONFIG_ARCH_FAMILY="armv7-m"
CONFIG_ARCH_CHIP="stm32"
# CONFIG_ARMV7M_USEBASEPRI is not set
CONFIG_ARCH_HAVE_CMNVECTOR=y
# CONFIG_ARMV7M_CMNVECTOR is not set
CONFIG_ARCH_HAVE_LAZYFPU=y
# CONFIG_ARMV7M_LAZYFPU is not set
CONFIG_ARCH_HAVE_FPU=y
# CONFIG_ARCH_HAVE_DPFPU is not set
......@@ -742,12 +742,12 @@ CONFIG_ARCH_LEDS=y
# ----- hn70ap board features -----
#
# CONFIG_HN70AP_HWDEBUG_BLINK is not set
# CONFIG_HN70AP_EEPROM is not set
# CONFIG_HN70AP_SPIFLASH is not set
# CONFIG_HN70AP_SCREEN is not set
# CONFIG_HN70AP_ETHERNET is not set
CONFIG_HN70AP_SCREEN=y
CONFIG_HN70AP_ETHERNET=y
CONFIG_HN70AP_RADIO=y
# CONFIG_HN70AP_MAINRADIO is not set
# CONFIG_HN70AP_AUXRADIO is not set
CONFIG_HN70AP_AUXRADIO=y
# CONFIG_HN70AP_AUXRADIO_HIGHPOWER is not set
# CONFIG_BOARD_CRASHDUMP is not set
CONFIG_LIB_BOARDCTL=y
CONFIG_BOARDCTL_RESET=y
......@@ -813,6 +813,7 @@ CONFIG_PTHREAD_MUTEX_ROBUST=y
#
# Performance Monitoring
#
# CONFIG_SCHED_IRQMONITOR is not set
# CONFIG_SCHED_CPULOAD is not set
# CONFIG_SCHED_INSTRUMENTATION is not set
......@@ -974,8 +975,8 @@ CONFIG_LCD_MAXPOWER=1
# CONFIG_LCD_MIO283QT2 is not set
# CONFIG_LCD_MIO283QT9A is not set
# CONFIG_LCD_UG9664HSWAG01 is not set
# CONFIG_LCD_SH1106_OLED_132 is not set
CONFIG_LCD_UG2864HSWEG01=y
CONFIG_LCD_SH1106_OLED_132=y
# CONFIG_LCD_UG2864HSWEG01 is not set
# CONFIG_LCD_UG2832HSWEG04 is not set
# CONFIG_LCD_DD12864WO4A is not set
# CONFIG_LCD_HILETGO is not set
......@@ -1018,6 +1019,7 @@ CONFIG_MTD=y
#
CONFIG_MTD_PARTITION=y
# CONFIG_MTD_SECT512 is not set
# CONFIG_MTD_PARTITION_NAMES is not set
# CONFIG_MTD_BYTE_WRITE is not set
# CONFIG_MTD_PROGMEM is not set
# CONFIG_MTD_CONFIG is not set
......@@ -1086,7 +1088,7 @@ CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y
#
# External Ethernet PHY Device Support
#
# CONFIG_ARCH_PHY_INTERRUPT is not set
CONFIG_ARCH_PHY_INTERRUPT=y
# CONFIG_ETH0_PHY_NONE is not set
# CONFIG_ETH0_PHY_AM79C874 is not set
# CONFIG_ETH0_PHY_KS8721 is not set
......@@ -1241,7 +1243,7 @@ CONFIG_NET_GUARDSIZE=2
#
# Link layer support
#
# CONFIG_NET_USER_DEVFMT is not set
CONFIG_NET_USER_DEVFMT=y
CONFIG_NET_ETHERNET=y
# CONFIG_NET_LOOPBACK is not set
CONFIG_NET_TUN=y
......@@ -1257,13 +1259,17 @@ CONFIG_TUN_HPWORK=y
CONFIG_NETDEV_IOCTL=y
CONFIG_NETDEV_PHY_IOCTL=y
# CONFIG_NETDEV_WIRELESS_IOCTL is not set
CONFIG_NETDEV_IFINDEX=y
#
# Internet Protocol Selection
#
CONFIG_NET_IPv4=y
# CONFIG_NET_IPv4_REASSEMBLY is not set
# CONFIG_NET_IPv6 is not set
# CONFIG_NET_IPFORWARD is not set
CONFIG_NET_IPFORWARD=y
# CONFIG_NET_IPFORWARD_BROADCAST is not set
CONFIG_NET_IPFORWARD_NSTRUCT=4
#
# Socket Support
......@@ -1272,6 +1278,7 @@ CONFIG_NSOCKET_DESCRIPTORS=8
CONFIG_NET_NACTIVESOCKETS=16
CONFIG_NET_SOCKOPTS=y
# CONFIG_NET_TCPPROTO_OPTIONS is not set
CONFIG_NET_UDPPROTO_OPTIONS=y
# CONFIG_NET_SOLINGER is not set
#
......@@ -1291,7 +1298,6 @@ CONFIG_NET_TCP=y
# CONFIG_NET_TCP_NO_STACK is not set
# CONFIG_NET_TCP_KEEPALIVE is not set
# CONFIG_NET_TCPURGDATA is not set
# CONFIG_NET_TCP_REASSEMBLY is not set
CONFIG_NET_TCP_CONNS=8
CONFIG_NET_MAX_LISTENPORTS=20
CONFIG_NET_TCP_READAHEAD=y
......@@ -1307,6 +1313,7 @@ CONFIG_NET_TCP_RECVDELAY=0
#
CONFIG_NET_UDP=y
# CONFIG_NET_UDP_NO_STACK is not set
CONFIG_NET_UDP_BINDTODEVICE=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NET_UDP_CONNS=8
CONFIG_NET_BROADCAST=y
......@@ -1395,7 +1402,25 @@ CONFIG_SMARTFS_MAXNAMLEN=16
# CONFIG_SMARTFS_MULTI_ROOT_DIRS is not set
# CONFIG_SMARTFS_ALIGNED_ACCESS is not set
# CONFIG_FS_BINFS is not set
# CONFIG_FS_PROCFS is not set
CONFIG_FS_PROCFS=y
# CONFIG_FS_PROCFS_REGISTER is not set
#
# Exclude individual procfs entries
#
# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set
# CONFIG_FS_PROCFS_EXCLUDE_BLOCKS is not set
# CONFIG_FS_PROCFS_EXCLUDE_MOUNT is not set
# CONFIG_FS_PROCFS_EXCLUDE_USAGE is not set
# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set
# CONFIG_FS_PROCFS_EXCLUDE_MEMINFO is not set
# CONFIG_FS_PROCFS_INCLUDE_PROGMEM is not set
# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set
# CONFIG_FS_PROCFS_EXCLUDE_NET is not set
# CONFIG_FS_PROCFS_EXCLUDE_MTD is not set
# CONFIG_FS_PROCFS_EXCLUDE_PARTITIONS is not set
# CONFIG_FS_PROCFS_EXCLUDE_ROUTE is not set
# CONFIG_FS_PROCFS_EXCLUDE_SMARTFS is not set
# CONFIG_FS_UNIONFS is not set
#
......@@ -1591,12 +1616,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
#
# CONFIG_CANUTILS_CANDUMP is not set
#
# Cryptographic tools
#
# CONFIG_CRYPTO_CT is not set
# CONFIG_CRYPTO_LIBCRYPTO is not set
#
# Examples
#
......@@ -1652,7 +1671,6 @@ CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_SERIALBLASTER is not set
# CONFIG_EXAMPLES_SERIALRX is not set
# CONFIG_EXAMPLES_SERLOOP is not set
# CONFIG_EXAMPLES_SI5351 is not set
# CONFIG_EXAMPLES_SLCD is not set
# CONFIG_EXAMPLES_SMART is not set
# CONFIG_EXAMPLES_SMART_TEST is not set
......@@ -1732,7 +1750,6 @@ CONFIG_HN70AP_UPDATE_STACKSIZE=2048
# CONFIG_INTERPRETERS_BAS is not set
# CONFIG_INTERPRETERS_FICL is not set
# CONFIG_INTERPRETERS_LUA is not set
# CONFIG_INTERPRETERS_MICROPYTHON is not set
# CONFIG_INTERPRETERS_MINIBASIC is not set
# CONFIG_INTERPRETERS_PCODE is not set
......@@ -1806,7 +1823,7 @@ CONFIG_NSH_DISABLE_EXEC=y
# CONFIG_NSH_DISABLE_GET is not set
# CONFIG_NSH_DISABLE_HELP is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
CONFIG_NSH_DISABLE_IFCONFIG=y
# CONFIG_NSH_DISABLE_IFCONFIG is not set
CONFIG_NSH_DISABLE_IFUPDOWN=y
# CONFIG_NSH_DISABLE_KILL is not set
CONFIG_NSH_DISABLE_LOSETUP=y
......@@ -1827,6 +1844,7 @@ CONFIG_NSH_DISABLE_PRINTF=y
# CONFIG_NSH_DISABLE_REBOOT is not set
# CONFIG_NSH_DISABLE_RM is not set
# CONFIG_NSH_DISABLE_RMDIR is not set
# CONFIG_NSH_DISABLE_ROUTE is not set
# CONFIG_NSH_DISABLE_SET is not set
# CONFIG_NSH_DISABLE_SH is not set
CONFIG_NSH_DISABLE_SHUTDOWN=y
......@@ -1849,6 +1867,7 @@ CONFIG_NSH_MMCSDMINOR=0
# CONFIG_NSH_CMDOPT_DD_STATS is not set
CONFIG_NSH_CODECS_BUFSIZE=128
CONFIG_NSH_CMDOPT_HEXDUMP=y
CONFIG_NSH_PROC_MOUNTPOINT="/proc"
CONFIG_NSH_FILEIOSIZE=512
#
......@@ -1915,6 +1934,11 @@ CONFIG_READLINE_ECHO=y
# CONFIG_SYSTEM_VI is not set
# CONFIG_SYSTEM_ZMODEM is not set
#
# Testing
#
# CONFIG_TESTING_UNITY is not set
#
# Wireless Libraries and NSH Add-Ons
#
......
......@@ -43,14 +43,12 @@ CSRCS += bootloader_gpio.c bootloader_uart.c bootloader_spi.c bootloader_intflas
CSRCS += bootloader_crc.c bootloader_tlv.c bootloader_spiflash.c
CSRCS += hn70ap_boot.c hn70ap_spi.c hn70ap_leds.c
ifeq ($(CONFIG_HN70AP_SPIFLASH),y)
#mandatory for firmware update
CSRCS += driver_mtdchar.c
CSRCS += hn70ap_flash.c
endif
ifeq ($(CONFIG_HN70AP_EEPROM),y)
#mandatory for apps
CSRCS += hn70ap_eeprom.c
endif
ifeq ($(CONFIG_HN70AP_SCREEN),y)
CSRCS += hn70ap_oled.c
......
......@@ -138,21 +138,17 @@ void board_initialize(void)
syslog(LOG_ERR, "ERROR: user leds init failed: %d\n", ret);
}
#if defined(CONFIG_HN70AP_SPIFLASH)
ret = hn70ap_flash_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: flash init failed: %d\n", ret);
}
#endif
#if defined(CONFIG_HN70AP_EEPROM)
ret = hn70ap_eeprom_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: eeprom init failed: %d\n", ret);
}
#endif
#if defined(CONFIG_HN70AP_SCREEN)
/* Initialize and register the framebuffer driver */
......
openocd \
-f interface/stlink-v2.cfg \
-c "transport select hla_swd" \
-c "reset_config none separate" \
-f target/stm32f4x.cfg
# -f interface/stlink-v2.cfg \
# -c "transport select hla_swd" \
openocd \
-f interface/stlink-v2.cfg \
-c "transport select hla_swd" \
-c "reset_config none separate" \
-f target/stm32f4x.cfg \
-c "program nuttx verify reset exit"
#init required before reset becomes available
#exit required to avoid running openocd as a server
openocd \
-f interface/stlink-v2.cfg \
-c "transport select hla_swd" \
-c "reset_config none separate" \
-f target/stm32f4x.cfg \
-c "init" \
-c "reset run" \
-c "exit"