Skip to content

Commit

Permalink
Add config option to select packet radio type.
Browse files Browse the repository at this point in the history
  • Loading branch information
gardners authored and lakeman committed Oct 1, 2014
1 parent db5daa2 commit 2296196
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
33 changes: 33 additions & 0 deletions conf_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,39 @@ int cf_fmt_interface_type(const char **textp, const short *typep)
return CFOK;
}

int cf_opt_radio_type(short *typep, const char *text)
{
if (strcasecmp(text, "rfd900") == 0) {
*typep = RADIO_TYPE_RFD900;
return CFOK;
}
if (strcasecmp(text, "rfm69") == 0) {
*typep = RADIO_TYPE_RFM69;
return CFOK;
}
return CFINVALID;
}

int cf_fmt_radio_type(const char **textp, const short *typep)
{
const char *t = NULL;
switch (*typep) {
case RADIO_TYPE_RFD900: t = "rfd900"; break;
case RADIO_TYPE_RFM69: t = "rfm69"; break;
}
if (!t)
return CFINVALID;
*textp = str_edup(t);
return CFOK;
}

int cf_cmp_radio_type(const short *a, const short *b)
{
return *a < *b ? -1 : *a > *b ? 1 : 0;
}



int cf_cmp_interface_type(const short *a, const short *b)
{
return *a < *b ? -1 : *a > *b ? 1 : 0;
Expand Down
1 change: 1 addition & 0 deletions conf_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ ATOM(bool_t, drop_broadcasts, 0, boolean,, "If true, drop all inc
ATOM(bool_t, drop_unicasts, 0, boolean,, "If true, drop all incoming unicast packets")
ATOM(uint16_t, drop_packets, 0, uint16_nonzero,, "Percentage of incoming packets that should be dropped for testing purposes")
ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_type,, "Type of network interface")
ATOM(short, radiotype, RADIO_TYPE_RFD900, radio_type,, "Type of packet radio interface")
SUB_STRUCT(mdp_iftype, mdp,)
ATOM(bool_t, send_broadcasts, 1, boolean,, "If false, don't send any broadcast packets")
ATOM(bool_t, default_route, 0, boolean,, "If true, use this interface as a default route")
Expand Down
3 changes: 3 additions & 0 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define OVERLAY_INTERFACE_WIFI 2
#define OVERLAY_INTERFACE_PACKETRADIO 3

#define RADIO_TYPE_RFD900 0
#define RADIO_TYPE_RFM69 1

#define OQ_ISOCHRONOUS_VOICE 0
#define OQ_MESH_MANAGEMENT 1
#define OQ_ISOCHRONOUS_VIDEO 2
Expand Down
2 changes: 1 addition & 1 deletion radio_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int radio_link_free(struct overlay_interface *interface)
{
if (interface->radio_link_state){
free(interface->radio_link_state);
interface->radio_link_state=NULL;
interface->radio_link_state=NULL;
}
return 0;
}
Expand Down

0 comments on commit 2296196

Please sign in to comment.