跳到主要内容

codless user replay() question

2年前

codless user replay() question

张贴了Gert186.0分 11回复
0旋转

你好,

我用1wire写了一个新的命令:

别的if(user_compare_cmd("1wire",1,2))
{
tm_onewire_t ow;
uint8_t port = ahtoi((char *)参数array [0]);
uint8_t port_number =端口/ 10;
uint8_t pin_number = port % 10;
UINT8_T DS_ROM [8];
char消息[8];
浮动温度;

tm_onewire_init(&ow,(gpio_port)port_number,(gpio_pin)pin_number);
tm_onewire_reset(&ow);

if (TM_OneWire_First(&OW)) {
// expanction.
tm_ds18b20_startall(&ow);
systick_wait(750000);//等待750ms.

/ *搜索下一个设备* /
做 {

tm_onewire_getfullrom(&ow,ds_rom);
tm_ds18b20_read(&ow,ds_rom和temp);
Sprintf(消息,“%x%x%x%x,%0.2f”,ds_rom [4],ds_rom [5],ds_rom [6],ds_rom [7],temp);// ds_rom [0],ds_rom [1],ds_rom [2],ds_rom [3],
//arch_printf("ATr+PRINT=%s\r",message);
user_reply(message,true);
} whiled(tm_onewire_next(&ow));
}
}

工作正常,但我想用user_replay将消息中的值发送给peer(消息,true)
void user_reply(char * reply_string,bool成功)
{
if(!deceless_env.suppress_response)
{
如果(成功)
{
//附加'确定'回复
if(strlen(reply_string)> 0)
sprintf(reply_string,“%s \ r \ nok”,Reply_String);
别的
Reply_String =“OK”;
}
别的
{
//报告“错误”
Sprintf(Reply_String,“错误”);
}

//如果命令源自那里,则回复BT对等体(仅当已连接)
if((dodeless_env.command_route == cmd_from_peer_resp_peer)&&(ke_state_get(task_app)== app_connected))
{
send_to_peer(reply_string);
}
别的if(codeless_env.command_route == CMD_FROM_LOCAL_RESP_LOCAL)
{
//通过串口本地回复
ARCH_PUTS(“\ r \ n”);
arch_puts(reply_string);
ARCH_PUTS(“\ r \ n”);
arch_printf_process();
}
//codeless_env.command_route = CMD_ROUTE_UNDEFINED;
}
}

我只有最后一个字符串。如果我安装了10个传感器,最后一个传感器.....

if i uncomment //codeless_env.command_route = CMD_ROUTE_UNDEFINED;
然后我只会得到第一个..

有人可以帮助我了解这个问题吗?

此致
Gert

2年前

mhv_dialog.

Hi Gert,

请尝试描述您想要完成的事情。单独列出的代码留下了太多未知数:o)

具体地说,我需要理解如果你actually trying to issue the command locally and want the reply to go back to the peer over the air. Also, I will need how much data you are trying to exchange. The reply string is limited to 160 characters.

/ mhv.

2年前

Gert186. 0分

好的,

我想从掌握到奴隶:

ATR + 1wire = 00开始从从站(在本例10)上的附加传感器上的读取,并在空中发送id和值回到主设备!
主站应将UART2上的值打印到终端。

命令发送和执行工作就像魅力。
但问题是它在空中向主人发送了一些东西,而是掌握只打印第一个
Codeless_env.command_route = cmd_route_unded 1时间
如果你有10次
//codeless_env.command_route = cmd_route_undined void user_reply(char * reply_string,bool成功)。

我不明白为什么他只打印出在UART2上的最后一个。

此致
Gert

2年前

mhv_dialog.

Hi Gert,

您正在打破命令的流程,因为您反复使用user_reply()。当收到远程处的AT命令时,无附加无附件将Dodeless_env.command_route设置为cmd_from_peer_resp_peer,这确保了回复返回到命令发起者。一旦回复为传输准备的BEN,Command_Route就会设置为CMD_Route_undeNined以允许接收下一个命令(通过蓝牙或UART)。

在您的循环中,而不是使用user_reply(),只需将整个响应记录回对等体。然后在循环之外,使用user_reply()将整个字符串传输为一个回复。这允许无附加的CommandFlow保持完整。但请记住,回复只能长为160个字符。

/ mhv.

2年前

Kevinl. 5 points

Hi Gert,

Please try to close the sleep mode before the testing.

此致

2年前

Gert186. 0分

我应该在哪里关闭睡眠模式?在user_replay函数中?

2年前

Kevinl. 5 points

在user_config.h.

将以下变量更改为ARCH_SLEEP_OFF。
/ ********************************************
*默认睡眠模式。可能的值是:
*
* - ARCH_SLEEP_OFF.
* - ARCH_EXT_SLEEP_ON.
* - ARCH_EXT_SLEEP_OTP_COPY_ON.
*
********************************************
* /
static const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF.; // ARCH_EXT_SLEEP_ON;

2年前

Gert186. 0分

没有变化!对不起

2年前

Gert186. 0分

对我来说,还有一些问题:

我无法在ARCH_PRINTF()的循环中在循环中打印超过231行。

它将在231行之后停止。

I think it is a time issue of checking or an interrupt from Advertising? Is there some expert with codeless who can help me?

2年前

PM_DIALOG.

嗨gert186,

您的描述几乎没有通用,请为我提供更多信息。你的意思是什么?你的意思是人物吗?如果您使用的是任何睡眠模式配置,请您告诉我吗?

谢谢,PM_DIALOG.

2年前

Gert186. 0分

没有关闭睡眠模式。

我打印出一个角色的231次,但它应该是1000 :-)角色是“1”

accepted answer!

2年前

PM_DIALOG.

嗨gert186,

您的描述仍然非常通用。有很多原因,你无法做到这一点。您能否分享您正在使用的代码片段?

谢谢,PM_DIALOG.