Skip to content
Snippets Groups Projects
Commit 29bf237e authored by genofire's avatar genofire Committed by schneider
Browse files

ble: svc card10 - add leds powersafe and flashlight

parent 223c5bbd
No related branches found
No related tags found
1 merge request!89ble: card10 srv - v2
...@@ -60,14 +60,19 @@ The current draft uses following service specification: ...@@ -60,14 +60,19 @@ The current draft uses following service specification:
UUID: ``42230216-2342-2342-2342-234223422342`` UUID: ``42230216-2342-2342-2342-234223422342``
write write
- LEDs above characteristic: - LEDs powersafe characteristic:
UUID: ``42230220-2342-2342-2342-234223422342`` UUID: ``42230217-2342-2342-2342-234223422342``
write
- flashlight characteristic:
UUID: ``42230218-2342-2342-2342-234223422342``
write write
- Single rgb led characteristic: - LEDs above characteristic:
UUID: ``422302ef-2342-2342-2342-234223422342`` UUID: ``42230220-2342-2342-2342-234223422342``
write write
- Light sensor characteristic: - Light sensor characteristic:
...@@ -129,26 +134,28 @@ LEDs dim <Position> characteristic ...@@ -129,26 +134,28 @@ LEDs dim <Position> characteristic
The LEDs dim <Position> characteristic makes it possible to dim LEDs by position. The LEDs dim <Position> characteristic makes it possible to dim LEDs by position.
Just write a ``uint8`` between ``1`` and ``8``. Just write a ``uint8`` between ``1`` and ``8``.
LEDs above characteristic LEDs powersafe characteristic
--------------------------------- ---------------------------------
This characteristic set every 11 leds on the top module at once.
Single rgb led characteristic This characteristic makes it possible to set the LEDs in powersafe mode.
--------------------------------- Even when set to zero, the RGB LEDs still individually consume ~1mA.
Powersave intelligently switches the supply power in groups.
This introduces delays in the magnitude of ~10µs, so it can be disabled for high speed applications such as POV
This characteristic makes it possible to address every single rgb led. - enabled: ``0x01``
Just write a byte array ``uint18`` address of led and three ``uint8`` for the rgb color. - disabled: ``0x00``
Dataformat: Flashlight characteristic
---------------------------------
====== ===== ===== ===== This characteristic makes it possible to activate the flashlight.
0-1 2 3 4
------ ----- ----- -----
led nr red green blue
- set led 14 red: ``0x0e00ff0000`` - enabled: ``0x01``
- set led 14 blue: ``0x0e000000ff`` - disabled: ``0x00``
- disable led 14: ``0x0e00000000``
LEDs above characteristic
---------------------------------
This characteristic set every 11 leds on the top module at once.
Light sensor characteristic Light sensor characteristic
--------------------------------- ---------------------------------
......
...@@ -46,8 +46,8 @@ static int lasttick = 0; ...@@ -46,8 +46,8 @@ static int lasttick = 0;
extern void StackInit(void); extern void StackInit(void);
extern void AppInit(void); extern void AppInit(void);
extern void bleuart_init(void); extern void bleuart_init(void);
extern void bleCard10_init(void);
extern void bleFileTransfer_init(void); extern void bleFileTransfer_init(void);
extern void bleCard10_init(void);
/*************************************************************************************************/ /*************************************************************************************************/
void PalSysAssertTrap(void) void PalSysAssertTrap(void)
...@@ -205,8 +205,8 @@ void vBleTask(void *pvParameters) ...@@ -205,8 +205,8 @@ void vBleTask(void *pvParameters)
AttsDynInit(); AttsDynInit();
bleuart_init(); bleuart_init();
bleCard10_init();
bleFileTransfer_init(); bleFileTransfer_init();
bleCard10_init();
lasttick = xTaskGetTickCount(); lasttick = xTaskGetTickCount();
......
...@@ -65,12 +65,15 @@ enum { ...@@ -65,12 +65,15 @@ enum {
/*!< \brief dim leds on top characteristic */ /*!< \brief dim leds on top characteristic */
CARD10_LEDS_TOP_DIM_CH_HDL, CARD10_LEDS_TOP_DIM_CH_HDL,
CARD10_LEDS_TOP_DIM_VAL_HDL, CARD10_LEDS_TOP_DIM_VAL_HDL,
/*!< \brief led powersafe characteristic */
CARD10_LED_POWERSAFE_CH_HDL,
CARD10_LED_POWERSAFE_VAL_HDL,
/*!< \brief flashlight characteristic */
CARD10_FLASHLIGHT_CH_HDL,
CARD10_FLASHLIGHT_VAL_HDL,
/*!< \brief leds above characteristic */ /*!< \brief leds above characteristic */
CARD10_LEDS_ABOVE_CH_HDL, CARD10_LEDS_ABOVE_CH_HDL,
CARD10_LEDS_ABOVE_VAL_HDL, CARD10_LEDS_ABOVE_VAL_HDL,
/*!< \brief single led characteristic */
CARD10_LED_S_CH_HDL,
CARD10_LED_S_VAL_HDL,
/*!< \brief light sensor characteristic */ /*!< \brief light sensor characteristic */
CARD10_LIGHT_SENSOR_CH_HDL, CARD10_LIGHT_SENSOR_CH_HDL,
CARD10_LIGHT_SENSOR_VAL_HDL, CARD10_LIGHT_SENSOR_VAL_HDL,
...@@ -188,6 +191,28 @@ static const uint8_t UUID_attChar_leds_top_dim[] = { ...@@ -188,6 +191,28 @@ static const uint8_t UUID_attChar_leds_top_dim[] = {
CARD10_UUID_SUFFIX, 0x16, CARD10_UUID_PREFIX CARD10_UUID_SUFFIX, 0x16, CARD10_UUID_PREFIX
}; };
/* BLE UUID for card10 powersafe */
static const uint8_t UUID_char_led_powersafe[] = {
ATT_PROP_WRITE,
UINT16_TO_BYTES(CARD10_LED_POWERSAFE_VAL_HDL),
CARD10_UUID_SUFFIX, 0x17, CARD10_UUID_PREFIX
};
static const uint8_t UUID_attChar_led_powersafe[] = {
CARD10_UUID_SUFFIX, 0x17, CARD10_UUID_PREFIX
};
/* BLE UUID for card10 flashlight */
static const uint8_t UUID_char_flashlight[] = {
ATT_PROP_WRITE,
UINT16_TO_BYTES(CARD10_FLASHLIGHT_VAL_HDL),
CARD10_UUID_SUFFIX, 0x18, CARD10_UUID_PREFIX
};
static const uint8_t UUID_attChar_flashlight[] = {
CARD10_UUID_SUFFIX, 0x18, CARD10_UUID_PREFIX
};
/* BLE UUID for card10 above leds */ /* BLE UUID for card10 above leds */
static const uint8_t UUID_char_leds_above[] = { static const uint8_t UUID_char_leds_above[] = {
ATT_PROP_WRITE, ATT_PROP_WRITE,
...@@ -198,17 +223,6 @@ static const uint8_t UUID_char_leds_above[] = { ...@@ -198,17 +223,6 @@ static const uint8_t UUID_char_leds_above[] = {
static const uint8_t UUID_attChar_leds_above[] = { static const uint8_t UUID_attChar_leds_above[] = {
CARD10_UUID_SUFFIX, 0x20, CARD10_UUID_PREFIX CARD10_UUID_SUFFIX, 0x20, CARD10_UUID_PREFIX
}; };
/* BLE UUID for card10 char led single (debugging) */
static const uint8_t UUID_char_led_s[] = {
ATT_PROP_WRITE,
UINT16_TO_BYTES(CARD10_LED_S_VAL_HDL),
CARD10_UUID_SUFFIX, 0xef, CARD10_UUID_PREFIX
};
static const uint8_t UUID_attChar_led_s[] = {
CARD10_UUID_SUFFIX, 0xef, CARD10_UUID_PREFIX
};
// starting at 0xf0 with read only characteristics // starting at 0xf0 with read only characteristics
/* BLE UUID for card10 char light sensor */ /* BLE UUID for card10 char light sensor */
...@@ -433,44 +447,65 @@ static void *addCard10GroupDyn(void) ...@@ -433,44 +447,65 @@ static void *addCard10GroupDyn(void)
ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC | ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH); ATTS_PERMIT_WRITE_AUTH);
// ABOVE LEDS // led powersafe
AttsDynAddAttrConst( AttsDynAddAttrConst(
pSHdl, pSHdl,
attChUuid, attChUuid,
UUID_char_leds_above, UUID_char_led_powersafe,
sizeof(UUID_char_leds_above), sizeof(UUID_char_led_powersafe),
0, 0,
ATTS_PERMIT_READ ATTS_PERMIT_READ
); );
AttsDynAddAttr( AttsDynAddAttr(
pSHdl, pSHdl,
UUID_attChar_leds_above, UUID_attChar_led_powersafe,
NULL, NULL,
0, 0,
11 * 3 * sizeof(uint8_t), sizeof(uint8_t),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH);
// flashlight
AttsDynAddAttrConst(
pSHdl,
attChUuid,
UUID_char_flashlight,
sizeof(UUID_char_flashlight),
0,
ATTS_PERMIT_READ
);
AttsDynAddAttr(
pSHdl,
UUID_attChar_flashlight,
NULL,
0,
sizeof(uint8_t),
ATTS_SET_WRITE_CBACK, ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC | ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH); ATTS_PERMIT_WRITE_AUTH);
// SINGLE LED // ABOVE LEDS
AttsDynAddAttrConst( AttsDynAddAttrConst(
pSHdl, pSHdl,
attChUuid, attChUuid,
UUID_char_led_s, UUID_char_leds_above,
sizeof(UUID_char_led_s), sizeof(UUID_char_leds_above),
0, 0,
ATTS_PERMIT_READ ATTS_PERMIT_READ
); );
AttsDynAddAttr( AttsDynAddAttr(
pSHdl, pSHdl,
UUID_attChar_led_s, UUID_attChar_leds_above,
NULL, NULL,
0, 0,
sizeof(uint16_t) + 3 * sizeof(uint8_t), 11 * 3 * sizeof(uint8_t),
ATTS_SET_WRITE_CBACK, ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC | ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC |
ATTS_PERMIT_WRITE_AUTH); ATTS_PERMIT_WRITE_AUTH);
...@@ -611,6 +646,16 @@ static uint8_t writeCard10CB( ...@@ -611,6 +646,16 @@ static uint8_t writeCard10CB(
} }
APP_TRACE_INFO1("dim top invalid value (1-8): %d\n", ui8); APP_TRACE_INFO1("dim top invalid value (1-8): %d\n", ui8);
return ATT_ERR_RANGE; return ATT_ERR_RANGE;
// led powersafe
case CARD10_LED_POWERSAFE_VAL_HDL:
epic_leds_set_powersave(pValue[0]);
APP_TRACE_INFO1("set powersafe to: %d\n", pValue[0]);
return ATT_SUCCESS;
// flashlight
case CARD10_FLASHLIGHT_VAL_HDL:
epic_set_flashlight(pValue[0]);
APP_TRACE_INFO1("set flashlight to: %d\n", pValue[0]);
return ATT_SUCCESS;
// leds above // leds above
case CARD10_LEDS_ABOVE_VAL_HDL: case CARD10_LEDS_ABOVE_VAL_HDL:
for (ui16 = 0; ui16 < 11; ui16++) { for (ui16 = 0; ui16 < 11; ui16++) {
...@@ -628,18 +673,6 @@ static uint8_t writeCard10CB( ...@@ -628,18 +673,6 @@ static uint8_t writeCard10CB(
pValue[ui16 * 3 + 2] pValue[ui16 * 3 + 2]
); );
} }
// single led
case CARD10_LED_S_VAL_HDL:
BYTES_TO_UINT16(ui16, pValue);
epic_leds_set(ui16, pValue[2], pValue[3], pValue[4]);
APP_TRACE_INFO4(
"ble-card10: set single led %ld to #%02x%02x%02x\n",
ui16,
pValue[2],
pValue[3],
pValue[4]
);
return ATT_SUCCESS;
default: default:
APP_TRACE_INFO1( APP_TRACE_INFO1(
"ble-card10: unsupported characteristic: %c\n", handle "ble-card10: unsupported characteristic: %c\n", handle
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment