Closed microbuilder closed 8 years ago
This is a good place to add stats as well, tracking the number of connects and disconnects to the system over time: https://github.com/adafruit/Adafruit_Mynewt/blob/master/apps/throughput/src/main.c
static int
bleprph_gap_event(struct ble_gap_event *event, void *arg)
{
switch (event->type) {
case BLE_GAP_EVENT_CONNECT:
/* A new connection was established or a connection attempt failed. */
if (event->connect.status == 0) {
bleuart_set_conn_handle(event->connect.conn_handle);
}else {
/* Connection failed; resume advertising. */
bleprph_advertise();
}
return 0;
case BLE_GAP_EVENT_DISCONNECT:
/* Connection terminated; resume advertising. */
bleprph_advertise();
return 0;
}
return 0;
}
Stats added to the 'dis' module in 8edad05d25ae86879579ddc779d6ae44612eefb1
Documentation on adding stats added via https://github.com/adafruit/Adafruit_Mynewt/blob/master/docs/13_statistics.md
Logging should still be added to this module so that we can use this as a reference for any future modules implemented.
To access the new DIS stats simply run the following command from the terminal:
$ newtmgr -c serial1 stat ble_svc_dis
Return Code = 0
Stats Name: ble_svc_dis
model_reads_stat: 1
serial_reads_stat: 0
firmware_rev_reads_stat: 1
hardware_rev_reads_stat: 1
software_rev_reads_stat: 1
manufacturer_reads_stat: 1
Or if you are using the console, run the stat ble_svc_dis
command.
stats also added to the nus service to track total bytes send and received via 71db8f095f0f0fbb1db71657123c1d77eaf7427b
stat ble_svc_nus
455001:txd_bytes: 200
455001:rxd_bytes: 21
Thanks for helpful info on stats.
For logging, it is already supported and INFO level. But I disable the LOG for throughput since INFO level will cause lots of BLE HS printout during the nustest
command.
https://github.com/adafruit/Adafruit_Mynewt/blob/master/apps/throughput/pkg.yml#L32
If LOG_LEVEL > 1 then LEVEL_INFO is not printed. Please try with bleuart, it have log level of 1, you should see those bledis logging.
#define LOG_LEVEL_DEBUG (0)
#define LOG_LEVEL_INFO (1)
#define LOG_LEVEL_WARN (2)
#define LOG_LEVEL_ERROR (3)
#define LOG_LEVEL_CRITICAL (4)
I still think bledis's stats is useless except for reference purpose which is already done in bleuart. We should just remove it from bledis.
To have a single good reference point for creating custom modules that we can easily debug in the field, the
libs/dis
helper should be update as follows:stats
support to track the number of times each characteristic is accessedThe logs and stats can then be accessed via
newtmgr
over serial, and will really help trying to solve customer issue in the field.It's also worth making the effort up front to follow the standards published here for any pull requests in the future: https://github.com/apache/incubator-mynewt-core/blob/master/CODING_STANDARDS.md ... although I don't agree with every decision like 4 line tabs, and typedef restrictions, etc.