创建许多海关服务

12 posts / 0 new
Last post
bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
创建许多海关服务

你好mt_dialog,

我已经使用了模板项目Yith Cust1和Cust2服务,现在我想有100个字段,所以什么可能是最好的方法?

我应该只有100个字段的一个服务,还是为Exemple 5服务创建和每项服务20个字段?

否则,是否有更好的解决方案?因为我需要在连接模式下发送100个变量到我的BLE应用程序。

Thank you,

关键词:
设备:
bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
Hello,

Hello,

I tried to create 20 fields in the cust1 service , but when I run the project , I got the error : RESET_MEM_ALLOC_FAIL (0xF2F2F2F2) in the wrap_platform_reset function. could it be fixed ? or I just reached the limits ?

Thank you,

Joacimwe.
Offline
最后一次露面:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
拥有100的想法

拥有100的想法characteristics seems bad. The service discovery time will take very long time and the memory allocations needed for all data structures would probably take up quite some large RAM.

你想做什么?
If you need to have the ability to set multiple variables remotely, you should implement some simple protocol using one characteristic, since you have your custom service anyway.
One solution is that when you write to the characteristic from your central, use the first byte to indicate which variable you would like to write to. The rest of the bytes consists of the actual value. Then in your gatt characteristic write handler, you simply check what the first byte is and act on that.

如果您还需要能够读取变量,您将无法直接使用GATT读取过程。而是使通知能够启用通知,并且如果使用特定值发送写命令(这将指示您想要读取),则会向包含该值的中央发送通知(哪些应该包括正在发送哪个变量)。或者如果您有通知,您希望在没有中央请求的情况下发送,通过包括可变ID和在特征值中的数据。为了确保通知并写入不会在一个特征上相互干扰,请确保您实际上从未在WRITE命令处理程序中使用ATTMDB_ATT_SET_VALUE。

bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
Thank you,

Thank you,

I already thought about this idea but the problem is that I want to send about 100 values to my Smartphone application that will display this data , and if I use just one characteristic , I should make 100 send operation before getting all values on the Smartphone app , so it will take a long time too and will be more complex.

但是这里只有20个特征,我得到了内存分配失败,所以我想我没有这么多选择..

Joacimwe.
Offline
最后一次露面:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
How large are your values?

How large are your values? Maybe you can pack them together and send many values in one notification?

It won't be any performance changes if you send a notification of the same characteristic multiple times or if you have many characteristics and send one notification each. It can still only send one packet at a time.

bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
让我们说2个字节

让我们说每变量2个字节,我认为特征的最大大小是16字节的右边?因此,如果它是真的,我需要超过10个特点..

Joacimwe.
Offline
最后一次露面:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
Hi.

Hi.

You can send 20 bytes in one notification.

That means you will have to send 10 notifications if you pack everything.

大多数智能手机每个连接事件都能容忍3-4个报文。这意味着您需要大约3个连接事件来发送所有内容。使用50 ms(Android默认值)的连接间隔,这将需要150毫秒。

mt_dialog.
Offline
最后一次露面:2个月3天前
Staff
Joined:2015-06-08 11:34
嗨bensalemsaif,

嗨bensalemsaif,

As Joacimwe suggested having 100 characteristics its a bad idea, and you should try as suggested to use somekind of a protocol and merge your values in one or more characteristics.

The fact that you ve got this indication (platform reset) means that you ve exausted the memory allocated for the database. How large the database can be depends on how memory the 580 can allocate for db purpose. Please check the below post on how to make your bd heap largerhttp://support.dialog-semiconductor.com/increasing-dbheapsz, but still packing your data in one or a bit more characteristics is a better choice.

谢谢mt_dialog.

bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
Hello,

Hello,

感谢你们答案的答案,我认为合并我的价值观将是最好的选择,但是你能向我解释如何做到这一点?直到现在,让我们说这是我有的:

- 字段UUID:128位
- 领域Char Len
- 现场用户描述
- ATT_CHAR128_DESC.
- 在我的数据库中:field_char,field_val和field_user_desc
I know that this function will update the databse because my data will change dynamically (i will get it using uart) :
attmdb_att_update_value(句柄,长度,偏移,值)

So now if I want to merge my values as you suggested in one field , should I just call the update function with a buffer containing all my values ? I did like that and I could put more than 20 bytes how is it possible ?
这里有一个屏幕截图,读取40字节的缓冲区

Thank you,

Joacimwe.
Offline
最后一次露面:1年5个月前
格鲁鲁
Joined:2014-01-14 06:45
The attributes themselves can

The attributes themselves can be larger than 20 bytes, but notifications can only be 20 bytes (unless you increase MTU).
您的中心最有可能使用称为“读取长特征值”的GATT功能。(有关详细信息,请参阅蓝牙规范。)

That procedure uses ATT Read Blob Requests repeatedly to retrieve all parts of the characteristic. In each request-response pair only 22 bytes can be transferred. The downside with this procedure is that it is ineffective. It takes approximately two roundtrips per part. If that is no problem for you, you can do it that way. With notifications you can send all of them at once (as many as can fit in one connection event).

如果您的中央支持,我还建议您增加MTU以便能够发送更大的数据包。
你也可以看看GATT part of the Bluetooth specification to see all available options.

What SDK are you using? If you use SDK5 and the custom service, to send notifications you use the CUSTS1_VAL_NTF_REQ message. When it has been processed and is ready to receive the next one, you will receive the CUSTS1_VAL_NTF_CFM message in user_peripheral.c. If you go for the Read Long Characteristic Values method, you simply send the message CUSTS1_VAL_SET_REQ and set your large characteristic value. Then the stack automatically handles the read requests from your central.

bensalemsaif
Offline
最后一次露面:3年8个月前
Joined:2016-02-02 12:42
Hello,

Hello,

I'm using SDK 5.0.3 and in my gapm.c file I have this value : GAP_MAX_LE_MTU_VAR = 512 , so It seems that my MTU = 512 right ?

现在有关通知,我能够在uart上获得新值时与这两条线一起发送我的数据:

attmdb_att_update_value((custs1_env.shdl + CUST1_IDX_FIELD1_VAL), length, offset, new_value)
prf_server_send_event((prf_env_struct *)&custs1_env,0,(custs1_env.shdl + cust1_idx_field1_val))

如果我在智能手机应用程序中启用通知,我可以看到我的新值是动态更新的,它是正确的吗?

谢谢,

mt_dialog.
Offline
最后一次露面:2个月3天前
Staff
Joined:2015-06-08 11:34
嗨bensalemsaif,

嗨bensalemsaif,

是的,只有在手机上启用通知时,您只能在客户端上接收数据。关于您使用要发送数据的代码,为什么您没有消息并让自定义配置文件句柄其余的,您只能分配custs1_val_ntf_req和相应的处理程序(custs1_val_ntf_req_handler)将使用与您的相同代码更新值正在使用。

谢谢mt_dialog.

Topic locked