Hello,
Let me first try to describe my whole project I just started with today (Hardware just arrived).
I want to use the nRF51-DK as a central device to handle 4 peripherals.
4 Peripherals (modules based on revision 2 nrf51822) - not accessible when in place:
- They are connected with either SPI (most likely) or I2C (TWI) with a sensor. Once at start they need to perform some communication with the sensor to set it up and get some coefficients.
- About every 4 seconds they shall
initiate two measurements (~10ms combined), get the results, do some fancy maths with it,
and then send the results to the
central. - Get a command from the central (e.g. is moving/not moving) and then eventually change their connection interval and/or TX power based on this
- They need to last as long as possible from a single coin cell (>900mAh CR2477) (ideally 4+ years)
Could be useful: DFU support (Possible to enter this mode when a secret command is received or something like that?)
1 Central (nrf51-dk, so revision 3) - remains accessible:
-
Shall connect to all 4 peripherals and get their measurement results every 4 seconds
-
Maybe do some more magic math with it
-
Send data out via UART (and maybe display them on a display) (At first the raw data from the peripherals, for creating an algorithm based on it, and later on the result of the algorithm)
I am still trying to figure out what will be the best way to achieve this with little previous knowledge in a short time (Thesis, but only a small first part of it..). So far I guess I will start trying to make the SPI Part work on its own (or mixed with UART for debugging, but probably the debugger would be better for that purpose), then try to setup an own service that could send the data via BT and later on then mix this into the Multilink Example and try to get it all working together. Any recommendations are very welcome!
At this specific time I was wondering how to time the measurements... They should preferable take place as soon as possible before the central asks the peripheral for its data.
Provided that it shall be a closed system of 4peripherals+1central in connection, I guess the connection interval can be kinda fixed. So probably this could be achieved by something like this:
Start a Timer after the connection. Let it count till <"4s interval" minus "time for measurement" minus "a little buffer"> and then start the measurement, so the new data is ready for the next connection. Any hints on how to implement this?
What would be the most useful in GATT: let the peripherals act as servers and the central as client? But then: Which of these events can be used for my task??
BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. @ref ble_gatts_evt_write_t */
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request.@ref ble_gatts_evt_rw_authorize_request_t */
BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set(). @ref ble_gatts_evt_sys_attr_missing_t */
BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. @ref ble_gatts_evt_hvc_t */
BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. No additional event structure applies. */
BLE_GATTS_EVT_TIMEOUT /**< Timeout. @ref ble_gatts_evt_timeout_t */
Why is there no such thing as a "Read performed event"? Don't the client "reads" the data from the server?
Thanks in advance!