Commit 0d322e7c authored by genofire's avatar genofire Committed by schneider
Browse files

ble: card10 svc - add single RGB led characteristic

parent a2693798
......@@ -30,6 +30,11 @@ The current draft uses following service specification:
UUID: ``42230210-2342-2342-2342-234223422342``
write
- Single rgb led characteristic:
UUID: ``422302ef-2342-2342-2342-234223422342``
write
- Light sensor characteristic:
UUID: ``422302f0-2342-2342-2342-234223422342``
......@@ -66,6 +71,23 @@ Rocket0 Rocket1 Rocket2
- Enable only Rocket0: ``0xff0000``
- Enable all rockets with 50% brightness: ``0x7f7f7f``
Single rgb led characteristic
---------------------------------
This characteristic makes it possible to address every single rgb led.
Just write a byte array ``uint18`` address of led and three ``uint8`` for the rgb color.
Dataformat:
====== ===== ===== =====
0-1 2 3 4
------ ----- ----- -----
led nr red green blue
- set led 14 red: ``0x0e00ff0000``
- set led 14 blue: ``0x0e000000ff``
- disable led 14: ``0x0e00000000``
Light sensor characteristic
---------------------------------
......
......@@ -47,6 +47,9 @@ enum {
/*!< \brief rockets led characteristic */
CARD10_ROCKETS_CH_HDL,
CARD10_ROCKETS_VAL_HDL,
/*!< \brief single led characteristic */
CARD10_LED_S_CH_HDL,
CARD10_LED_S_VAL_HDL,
/*!< \brief light sensor characteristic */
CARD10_LIGHT_SENSOR_CH_HDL,
CARD10_LIGHT_SENSOR_VAL_HDL,
......@@ -98,6 +101,16 @@ static const uint8_t UUID_attChar_rockets[] = {
CARD10_UUID_SUFFIX, 0x10, CARD10_UUID_PREFIX
};
/* BLE UUID for card10 char led single (debugging) */
static const uint8_t UUID_char_led_s[] = {
ATT_PROP_WRITE_NO_RSP,
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
/* BLE UUID for card10 char light sensor */
......@@ -196,6 +209,27 @@ static void *addCard10GroupDyn(void)
ATTS_PERMIT_WRITE
);
// SINGLE LED
AttsDynAddAttrConst(
pSHdl,
attChUuid,
UUID_char_led_s,
sizeof(UUID_char_led_s),
0,
ATTS_PERMIT_READ
);
AttsDynAddAttr(
pSHdl,
UUID_attChar_led_s,
NULL,
0,
sizeof(uint16_t) + 3 * sizeof(uint8_t),
ATTS_SET_WRITE_CBACK,
ATTS_PERMIT_WRITE
);
// LIGHT_SENSOR
AttsDynAddAttrConst(
......@@ -281,6 +315,17 @@ static uint8_t writeCard10CB(
pValue[2]
);
return ATT_SUCCESS;
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 #%x%x%x\n",
ui16,
pValue[2],
pValue[3],
pValue[4]
);
return ATT_SUCCESS;
default:
APP_TRACE_INFO1(
"ble-card10: unsupported characteristic: %c\n", handle
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment