attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = sizeof(uint8_t);
attr_char_value.init_offs = 0;
attr_char_value.max_len = sizeof(uint8_t);
attr_char_value.p_value = NULL;
This is original code used for both LED and BUTTON characteristis. It this replacement is valid( the way I understand the intend)?
typedef enum {LED_OFF, LED_ON} led_state_t;
...
attr_char_value.init_len = sizeof(led_state_t);
attr_char_value.max_len = sizeof(led_state_t);
...
typedef enum {BUTTON_PRESSED, BUTTON_RELEASED } button_state_t;
...
attr_char_value.init_len = sizeof(button_state_t);
attr_char_value.max_len = sizeof(button_state_t);
...
I do realize that using enum makes such types compiler and its options dependent and using uint8_t may save memory. There are other possible implementations like typedef bool led_state_t; or even typedef uint8_t led_state_t; and so on but at least I can see what exactly type is used and don't hyave to guess what uint8_t is representing is every case.
Thank you.