Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions chibi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ void chibiInit()
chb_init();
}

/**************************************************************************/
/*!
Initialize the command echo and prompt display settings
*/
/**************************************************************************/

void chibiDisplayFlags(char prompt, char echo)
{
cmd_prompt_flag = prompt;
cmd_echo_flag = echo;
}

/**************************************************************************/
/*!
Set the short address of the wireless node. This is the 16-bit "nickname"
Expand Down
1 change: 1 addition & 0 deletions chibi.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define BROADCAST_ADDR 0xFFFF

void chibiInit();
void chibiDisplayFlags(char prompt, char echo);
void chibiSetShortAddr(uint16_t addr);
uint16_t chibiGetShortAddr();
void chibiSetIEEEAddr(uint8_t *ieee_addr);
Expand Down
21 changes: 18 additions & 3 deletions src/chb_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ const char cmd_banner[] PROGMEM = "*************** CHIBI *******************";
const char cmd_prompt[] PROGMEM = "CHIBI >> ";
const char cmd_unrecog[] PROGMEM = "CHIBI: Command not recognized.";

int cmd_prompt_flag = 1;
int cmd_echo_flag = 1;

/**************************************************************************/
/*!
Generate the main command prompt
*/
/**************************************************************************/
static void chb_cmd_display()
{
if(cmd_prompt_flag==0)
return;

char buf[50];

Serial.println();
Expand Down Expand Up @@ -142,14 +148,20 @@ static void chb_cmd_handler()
// terminate the msg and reset the msg ptr. then send
// it to the handler for processing.
*msg_ptr = '\0';
Serial.print("\r\n");
if(cmd_echo_flag==1)
{
Serial.print("\r\n");
}
chb_cmd_parse((char *)msg);
msg_ptr = msg;
break;

case '\b':
// backspace
Serial.print(c);
if(cmd_echo_flag==1)
{
Serial.print(c);
}
if (msg_ptr > msg)
{
msg_ptr--;
Expand All @@ -162,7 +174,10 @@ static void chb_cmd_handler()
if ((msg_ptr - msg) < (MAX_MSG_SIZE - 1))
{
// normal character entered. add it to the buffer
Serial.print(c);
if(cmd_echo_flag==1)
{
Serial.print(c);
}
*msg_ptr++ = c;
}
break;
Expand Down