Skip to content
Commits on Source (4)
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.beacon in the NuttX tools repository.
#
config HN70AP_BEACON
bool "RF beacon"
default n
---help---
Radio beacon regularly transmitting packets on RF.
if HN70AP_BEACON
config HN70AP_BEACON_PROGNAME
string "Program name"
default "beacon"
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
config HN70AP_BEACON_PRIORITY
int "beacon task priority"
default 100
config HN70AP_BEACON_STACKSIZE
int "beacon stack size"
default 2048
endif
############################################################################
# hn70ap/apps/beacon/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 20158 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.
#
############################################################################
ifeq ($(CONFIG_HN70AP_BEACON),y)
CONFIGURED_APPS += hn70ap/beacon
endif
############################################################################
# hn70ap/apps/beacon/Makefile
#
# Copyright (C) 2008, 2010-2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
# 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 $(TOPDIR)/Make.defs
# RX test built-in application info
CONFIG_HN70AP_BEACON_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_HN70AP_BEACON_STACKSIZE ?= 2048
APPNAME = beacon
PRIORITY = $(CONFIG_HN70AP_BEACON_PRIORITY)
STACKSIZE = $(CONFIG_HN70AP_BEACON_STACKSIZE)
ASRCS =
CSRCS =
MAINSRC = beacon_main.c
CONFIG_HN70AP_BEACON_PROGNAME ?= $(APPNAME)$(EXEEXT)
PROGNAME = $(CONFIG_HN70AP_BEACON_PROGNAME)
include $(APPDIR)/Application.mk
/****************************************************************************
* hn70ap/apps/beacon/beacon_main.c
*
* Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <hn70ap/eeprom.h>
/****************************************************************************
* Public Functions
****************************************************************************/
int beacon_usage(void)
{
printf(
"beacon [device] <ascii payload>\n"
);
return ERROR;
}
/****************************************************************************
* status_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int beacon_main(int argc, char *argv[])
#endif
{
char *devname = "/dev/raux";
char *data;
int ret = OK;
int fd;
int buflen = 1024;
uint32_t seqnum = 0;
char call[9];
uint8_t ssid;
uint8_t *buf;
if(argc == 3)
{
devname = argv[1];
data = argv[2];
}
else if(argc == 2)
{
data = argv[1];
}
else
{
return beacon_usage();
}
buf = malloc(buflen);
if(!buf)
{
fprintf(stderr, "malloc failed!\n");
ret = ERROR;
goto done;
}
fd = open(devname, O_RDWR);
if(fd<0)
{
fprintf(stderr, "open failed!\n");
ret = ERROR;
goto retfree;
}
printf("\nTX beacon using %s\n", devname);
/* Define payload */
hn70ap_eeconfig_getcall("call", call);
call[8] = 0;
hn70ap_eeconfig_getbyte("ssid", &ssid);
if(strlen(call)==0)
{
fprintf(stderr, "call sign not defined, see config app\n");
ret = ERROR;
goto retclose;
}
while(1)
{
sprintf(buf, "de %s/%d, seq=%u, hn70ap beacon: %s\n", call, ssid, seqnum, data);
printf("%s", buf);
ret = write(fd, buf, strlen(buf));
if(ret < 0)
{
printf("write failed, errno=%d\n", errno);
break;
}
seqnum += 1;
}
retclose:
close(fd);
retfree:
free(buf);
done:
return ret;
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
config HN70AP_CONFIG config HN70AP_CONFIG
bool "hn70ap system configuration app" bool "system configuration app"
default y default y
---help--- ---help---
The config app manages the system settings. The config app manages the system settings.
...@@ -20,11 +20,11 @@ config HN70AP_CONFIG_PROGNAME ...@@ -20,11 +20,11 @@ config HN70AP_CONFIG_PROGNAME
program is installed. program is installed.
config HN70AP_CONFIG_PRIORITY config HN70AP_CONFIG_PRIORITY
int "hn70ap config task priority" int "config task priority"
default 100 default 100
config HN70AP_CONFIG_STACKSIZE config HN70AP_CONFIG_STACKSIZE
int "hn70ap config stack size" int "config stack size"
default 2048 default 2048
endif endif
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -63,7 +64,7 @@ int config_list(void) ...@@ -63,7 +64,7 @@ int config_list(void)
ret = hn70ap_eeconfig_describe(i, name, sizeof(name), &type); ret = hn70ap_eeconfig_describe(i, name, sizeof(name), &type);
if(ret == OK) if(ret == OK)
{ {
printf("name:%s type:%d value:", name, type); printf("%8s = ", name, type);
if(type == EECONFIG_TYPE_BOOL) if(type == EECONFIG_TYPE_BOOL)
{ {
bool val; bool val;
...@@ -82,6 +83,25 @@ int config_list(void) ...@@ -82,6 +83,25 @@ int config_list(void)
printf("%s\n", inet_ntoa(val)); printf("%s\n", inet_ntoa(val));
} }
} }
else if(type == EECONFIG_TYPE_BYTE)
{
uint8_t val;
ret = hn70ap_eeconfig_getbyte(name, &val);
if(ret == OK)
{
printf("%d (0x%02X)\n", val, val);
}
}
else if(type == EECONFIG_TYPE_CALL)
{
char val[9];
memset(val, 0, sizeof(val));
ret = hn70ap_eeconfig_getcall(name, val);
if(ret == OK)
{
printf("%s\n", val);
}
}
if(ret != OK) if(ret != OK)
{ {
printf("<unreadable>\n"); printf("<unreadable>\n");
......
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <hn70ap/eeprom.h> #include <hn70ap/eeprom.h>
...@@ -48,8 +52,104 @@ ...@@ -48,8 +52,104 @@
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
int config_set(char *key, char *val) int config_set(char *key, char *value)
{ {
return ERROR; char name[16];
uint32_t type;
int ret;
int index;
/* Get config entry */
index = hn70ap_eeconfig_find(key);
if(index<0)
{
fprintf(stderr, "Config entry '%s' not found\n", key);
return ERROR;
}
ret = hn70ap_eeconfig_describe(index, name, sizeof(name), &type);
if(ret != OK)
{
fprintf(stderr, "Config entry '%s' not usable\n", key);
return ERROR;
}
if(type == EECONFIG_TYPE_BOOL)
{
bool val;
printf("Entry type is bool\n");
if(!strcmp(value, "true") ||
!strcmp(value, "True") ||
!strcmp(value, "TRUE") ||
!strcmp(value, "yes") ||
!strcmp(value, "Yes") ||
!strcmp(value, "YES") ||
!strcmp(value, "y") ||
!strcmp(value, "Y") ||
!strcmp(value, "1")
)
{
val = true;
}
else if(!strcmp(value, "false") ||
!strcmp(value, "False") ||
!strcmp(value, "FALSE") ||
!strcmp(value, "no") ||
!strcmp(value, "No") ||
!strcmp(value, "NO") ||
!strcmp(value, "n") ||
!strcmp(value, "N") ||
!strcmp(value, "0")
)
{
val = false;
}
else
{
printf("Unrecognized boolean value: %s\n",value);
return ERROR;
}
ret = hn70ap_eeconfig_setbool(name, val);
}
else if(type == EECONFIG_TYPE_IP)
{
in_addr_t val;
printf("Entry type is IPv4\n");
ret = inet_pton(AF_INET, value, &val);
if(ret != 1)
{
printf("Invalid IPv4 address: %s\n", value);
return ERROR;
}
ret = hn70ap_eeconfig_setip(name, val);
}
else if(type == EECONFIG_TYPE_CALL)
{
printf("Entry type is call\n");
ret = hn70ap_eeconfig_setcall(name, value);
}
else if(type == EECONFIG_TYPE_BYTE)
{
unsigned long int val;
printf("Entry type is byte\n");
val = strtoul(value,NULL,0);
if(val > 0xFF)
{
printf("Invalid byte: %s\n", value);
return ERROR;
}
else
{
ret = hn70ap_eeconfig_setbyte(name, val);
}
}
else
{
fprintf(stderr, "Unknown entry type!\n");
return ERROR;
}
return ret;
} }
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#define EECONFIG_TYPE_BOOL 1 /* 8 bools mapped in 1 byte */ #define EECONFIG_TYPE_BOOL 1 /* 8 bools mapped in 1 byte */
#define EECONFIG_TYPE_IP 2 /* 4 bytes */ #define EECONFIG_TYPE_IP 2 /* 4 bytes */
#define EECONFIG_TYPE_CALL 3 /* 8 bytes */
#define EECONFIG_TYPE_BYTE 4 /* 1 byte */
/* Name of the EEPROM device */ /* Name of the EEPROM device */
...@@ -16,9 +18,18 @@ ...@@ -16,9 +18,18 @@
/* Initialize the EEPROM configuration management */ /* Initialize the EEPROM configuration management */
int hn70ap_eeconfig_init(bool *default_set); int hn70ap_eeconfig_init(bool *default_set);
int hn70ap_eeconfig_find(char *name);
int hn70ap_eeconfig_describe(int index, char *namebuf, int namebuflen, uint32_t *type); int hn70ap_eeconfig_describe(int index, char *namebuf, int namebuflen, uint32_t *type);
int hn70ap_eeconfig_getbool(char *name, bool *value); int hn70ap_eeconfig_getbool(char *name, bool *value);
int hn70ap_eeconfig_getip(char *name, struct in_addr *value); int hn70ap_eeconfig_getip (char *name, in_addr_t *value);
int hn70ap_eeconfig_getbyte(char *name, uint8_t *value);
int hn70ap_eeconfig_getcall(char *name, char *value);
int hn70ap_eeconfig_setbool(char *name, bool value);
int hn70ap_eeconfig_setip (char *name, in_addr_t value);
int hn70ap_eeconfig_setbyte(char *name, uint8_t value);
int hn70ap_eeconfig_setcall(char *name, char *value);
int hn70ap_eeprom_read (uint32_t addr, uint8_t *buf, uint32_t len); int hn70ap_eeprom_read (uint32_t addr, uint8_t *buf, uint32_t len);
int hn70ap_eeprom_write(uint32_t addr, uint8_t *buf, uint32_t len); int hn70ap_eeprom_write(uint32_t addr, uint8_t *buf, uint32_t len);
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
# #
config LIBHN70AP config LIBHN70AP
bool "hn70ap common Library" bool "Common Library"
default y default y
...@@ -67,13 +67,15 @@ struct param_s ...@@ -67,13 +67,15 @@ struct param_s
const struct param_s eeconfig_params[] = const struct param_s eeconfig_params[] =
{ {
{"dhcp", EECONFIG_TYPE_BOOL, 1, 0x01}, /* 0x01 - 0x01 DHCP Client Enable */ {"dhcp", EECONFIG_TYPE_BOOL, 0x01, 0x01}, /* 0x01 - 0x01 DHCP Client Enable */
/* 0x02 - 0x03 RFU for more network options */ /* 0x02 - 0x03 RFU for more network options */
{"ip" , EECONFIG_TYPE_IP , 4, 0}, /* 0x04 - 0x07 Static IP address to use if DHCP is not enabled */ {"ip" , EECONFIG_TYPE_IP , 0x04, 0}, /* 0x04 - 0x07 Static IP address to use if DHCP is not enabled */
{"mask", EECONFIG_TYPE_IP , 8, 0}, /* 0x08 - 0x0B Static IP mask to use if DHCP is not enabled */ {"mask", EECONFIG_TYPE_IP , 0x08, 0}, /* 0x08 - 0x0B Static IP mask to use if DHCP is not enabled */
{"gw" , EECONFIG_TYPE_IP , 12, 0}, /* 0x0C - 0x0F IP address of default gateway */ {"gw" , EECONFIG_TYPE_IP , 0x0C, 0}, /* 0x0C - 0x0F IP address of default gateway */
{"dns" , EECONFIG_TYPE_IP , 16, 0}, /* 0x10 - 0x13 IP address of DNS server (independent of DHCP enable)*/ {"dns" , EECONFIG_TYPE_IP , 0x10, 0}, /* 0x10 - 0x13 IP address of DNS server (independent of DHCP enable)*/
/* 0x14 - 0x7F RFU for more network options */ {"call", EECONFIG_TYPE_CALL, 0x14, 0}, /* 0x14 - 0x1B HAM callsign, zero padded */
{"ssid", EECONFIG_TYPE_BYTE, 0x1C, 0}, /* 0x1C - 0x1C HAM Station ID */
/* 0x1D - 0x7F RFU for more options */
}; };
#define EECONFIG_PARAMS_COUNT (sizeof(eeconfig_params) / sizeof(eeconfig_params[0])) #define EECONFIG_PARAMS_COUNT (sizeof(eeconfig_params) / sizeof(eeconfig_params[0]))
...@@ -97,7 +99,11 @@ int hn70ap_eeconfig_init(bool *default_set) ...@@ -97,7 +99,11 @@ int hn70ap_eeconfig_init(bool *default_set)
/* Not set? Set defaults */ /* Not set? Set defaults */
if( buf != HN70AP_CONFIG_INSTALLED) if( buf != HN70AP_CONFIG_INSTALLED)
{ {
/* Everything is set to FFFFh */
*default_set = true; *default_set = true;
/* Clean ham call */
hn70ap_eeconfig_setcall("call", "");
buf = HN70AP_CONFIG_INSTALLED; buf = HN70AP_CONFIG_INSTALLED;
hn70ap_eeprom_write(0, &buf, 1); hn70ap_eeprom_write(0, &buf, 1);
} }
...@@ -111,24 +117,26 @@ int hn70ap_eeconfig_init(bool *default_set) ...@@ -111,24 +117,26 @@ int hn70ap_eeconfig_init(bool *default_set)
int hn70ap_eeprom_read(uint32_t addr, uint8_t *buf, uint32_t len) int hn70ap_eeprom_read(uint32_t addr, uint8_t *buf, uint32_t len)
{ {
int fd; int fd;
int ret = OK;
fd = open(HN70AP_EECONFIG_DEVICE, O_RDONLY); fd = open(HN70AP_EECONFIG_DEVICE, O_RDONLY);
if(fd < 0) if(fd < 0)
{ {
return ERROR; return ERROR;
} }
if(lseek(fd, addr, SEEK_SET) != OK) if(lseek(fd, addr, SEEK_SET) != addr)
{ {
close(fd); ret = ERROR;
return ERROR; goto done;
} }
if(read(fd, buf, len) != len) if(read(fd, buf, len) != len)
{ {
close(fd); ret = ERROR;
return ERROR; goto done;
} }
done:
close(fd); close(fd);
return OK; return ret;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
...@@ -141,7 +149,7 @@ int hn70ap_eeprom_write(uint32_t addr, uint8_t *buf, uint32_t len) ...@@ -141,7 +149,7 @@ int hn70ap_eeprom_write(uint32_t addr, uint8_t *buf, uint32_t len)
{ {
return ERROR; return ERROR;
} }
if(lseek(fd, addr, SEEK_SET) != OK) if(lseek(fd, addr, SEEK_SET) != addr)
{ {
close(fd); close(fd);
return ERROR; return ERROR;
...@@ -172,7 +180,7 @@ int hn70ap_eeconfig_describe(int index, char *namebuf, int namebuflen, uint32_t ...@@ -172,7 +180,7 @@ int hn70ap_eeconfig_describe(int index, char *namebuf, int namebuflen, uint32_t
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int hn70ap_eeconfig_find(char *name) int hn70ap_eeconfig_find(char *name)
{ {
int i; int i;
for(i = 0; i < EECONFIG_PARAMS_COUNT; i++) for(i = 0; i < EECONFIG_PARAMS_COUNT; i++)
...@@ -188,9 +196,10 @@ static int hn70ap_eeconfig_find(char *name) ...@@ -188,9 +196,10 @@ static int hn70ap_eeconfig_find(char *name)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_getbool(char *name, bool *value) int hn70ap_eeconfig_getbool(char *name, bool *value)
{ {
int index = hn70ap_eeconfig_find(name);
int ret; int ret;
uint8_t buf; uint8_t buf;
int index = hn70ap_eeconfig_find(name);
if(index < 0) if(index < 0)
{ {
return ERROR; return ERROR;
...@@ -211,10 +220,11 @@ int hn70ap_eeconfig_getbool(char *name, bool *value) ...@@ -211,10 +220,11 @@ int hn70ap_eeconfig_getbool(char *name, bool *value)
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_getip(char *name, struct in_addr *value) int hn70ap_eeconfig_getip(char *name, in_addr_t *value)
{ {
int index = hn70ap_eeconfig_find(name);
int ret; int ret;
int index = hn70ap_eeconfig_find(name);
if(index < 0) if(index < 0)
{ {
return ERROR; return ERROR;
...@@ -233,3 +243,188 @@ int hn70ap_eeconfig_getip(char *name, struct in_addr *value) ...@@ -233,3 +243,188 @@ int hn70ap_eeconfig_getip(char *name, struct in_addr *value)
return OK; return OK;
} }
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_getbyte(char *name, uint8_t *value)
{
int ret;
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_BYTE)
{
return ERROR;
}
ret = hn70ap_eeprom_read(eeconfig_params[index].addr, value, 1);
if(ret != OK)
{
return ERROR;
}
return OK;
}
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_getcall(char *name, char *value)
{
int ret;
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_CALL)
{
return ERROR;
}
ret = hn70ap_eeprom_read(eeconfig_params[index].addr, (uint8_t*)value, 8);
if(ret != OK)
{
return ERROR;
}
return OK;
}
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_setbool(char *name, bool value)
{
int ret;
uint8_t buf;
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_BOOL)
{
return ERROR;
}
ret = hn70ap_eeprom_read(eeconfig_params[index].addr, &buf, 1);
if(ret != OK)
{
return ERROR;
}
if(value)
{
buf |= eeconfig_params[index].mask;
}
else
{
buf &= ~eeconfig_params[index].mask;
}
ret = hn70ap_eeprom_write(eeconfig_params[index].addr, &buf, 1);
if(ret != OK)
{
return ERROR;
}
return OK;
}
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_setip(char *name, in_addr_t value)
{
int ret;
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_IP)
{
return ERROR;
}
ret = hn70ap_eeprom_write(eeconfig_params[index].addr, (uint8_t*)&value, 4);
if(ret != OK)
{
return ERROR;
}
return OK;
}
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_setbyte(char *name, uint8_t value)
{
int ret;
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_BYTE)
{
return ERROR;
}
ret = hn70ap_eeprom_write(eeconfig_params[index].addr, &value, 1);
if(ret != OK)
{
return ERROR;
}
return OK;
}
/*----------------------------------------------------------------------------*/
int hn70ap_eeconfig_setcall(char *name, char *value)
{
int ret;
int i;
int len;
char call[8];
int index = hn70ap_eeconfig_find(name);
if(index < 0)
{
return ERROR;
}
if(eeconfig_params[index].type != EECONFIG_TYPE_CALL)
{
return ERROR;
}
/* Format callsign: only allow letters and numbers, turn into uppercase */
len = strlen(value);
if(len > 8)
{
len = 8;
}
for(i=0;i<len;i++)
{
if(value[i] >= 'a' && value[i] <= 'z')
{
call[i] = value[i] - 'a' + 'A';
}
else if(value[i] >= 'A' && value[i] <= 'Z')
{
call[i] = value[i];
}
else if(value[i] >= '0' && value[i] <= '9')
{
call[i] = value[i];
}
else
{
return ERROR;
}
}
for(;i<8;i++)
{
call[i] = 0; /* Padding */
}
ret = hn70ap_eeprom_write(eeconfig_params[index].addr, (uint8_t*)call, 8);
if(ret != OK)
{
return ERROR;
}
return OK;
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
config HN70AP_RXT config HN70AP_RXT
bool "hn70ap RX test" bool "RX test"
default y default y
---help--- ---help---
Test Radio Reception. Test Radio Reception.
...@@ -20,11 +20,11 @@ config HN70AP_RXT_PROGNAME ...@@ -20,11 +20,11 @@ config HN70AP_RXT_PROGNAME
program is installed. program is installed.
config HN70AP_RXT_PRIORITY config HN70AP_RXT_PRIORITY
int "hn70ap rxt task priority" int "rxt task priority"
default 100 default 100
config HN70AP_RXT_STACKSIZE config HN70AP_RXT_STACKSIZE
int "hn70ap rxt stack size" int "rxt stack size"
default 2048 default 2048
endif endif
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
config HN70AP_SYSDAEMON config HN70AP_SYSDAEMON
bool "hn70ap system daemon" bool "system daemon"
default y default y
---help--- ---help---
The system daemon manages the ethernet link status, the oled screen, then starts nsh. The system daemon manages the ethernet link status, the oled screen, then starts nsh.
...@@ -20,11 +20,11 @@ config HN70AP_SYSDAEMON_PROGNAME ...@@ -20,11 +20,11 @@ config HN70AP_SYSDAEMON_PROGNAME
program is installed. program is installed.
config HN70AP_SYSDAEMON_PRIORITY config HN70AP_SYSDAEMON_PRIORITY
int "hn70ap sysdaemon task priority" int "sysdaemon task priority"
default 100 default 100
config HN70AP_SYSDAEMON_STACKSIZE config HN70AP_SYSDAEMON_STACKSIZE
int "hn70ap sysdaemon stack size" int "sysdaemon stack size"
default 2048 default 2048
endif endif
...@@ -80,6 +80,7 @@ int sysdaemon_main(int argc, char *argv[]) ...@@ -80,6 +80,7 @@ int sysdaemon_main(int argc, char *argv[])
#endif #endif
{ {
bool defaults; bool defaults;
char call[9];
printf("\nhn70ap system daemon starting\n"); printf("\nhn70ap system daemon starting\n");
hn70ap_eeconfig_init(&defaults); hn70ap_eeconfig_init(&defaults);
...@@ -87,6 +88,12 @@ int sysdaemon_main(int argc, char *argv[]) ...@@ -87,6 +88,12 @@ int sysdaemon_main(int argc, char *argv[])
{ {
printf("WARNING: Default config values loaded in EEPROM\n"); printf("WARNING: Default config values loaded in EEPROM\n");
} }
else
{
hn70ap_eeconfig_getcall("call", call);
call[8] = 0;
printf("Hello %s, best 73's\n", call);
}
hn70ap_mount_storage(); hn70ap_mount_storage();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
config HN70AP_TXT config HN70AP_TXT
bool "hn70ap TX test" bool "TX test"
default y default y
---help--- ---help---
Test Radio Transmission. Test Radio Transmission.
...@@ -20,11 +20,11 @@ config HN70AP_TXT_PROGNAME ...@@ -20,11 +20,11 @@ config HN70AP_TXT_PROGNAME
program is installed. program is installed.
config HN70AP_TXT_PRIORITY config HN70AP_TXT_PRIORITY
int "hn70ap txt task priority" int "txt task priority"
default 100 default 100
config HN70AP_TXT_STACKSIZE config HN70AP_TXT_STACKSIZE
int "hn70ap txt stack size" int "txt stack size"
default 2048 default 2048
endif endif
...@@ -67,7 +67,6 @@ int update_write_start(struct update_context_s *ctx) ...@@ -67,7 +67,6 @@ int update_write_start(struct update_context_s *ctx)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
int update_write(struct update_context_s *ctx, uint8_t *buf, uint32_t len) int update_write(struct update_context_s *ctx, uint8_t *buf, uint32_t len)
{ {
int retval = OK; //default will proceed with next packet after this one.
int room; int room;
int off = 0; int off = 0;
int ret; /* ioctl return values */ int ret; /* ioctl return values */
......