static void test_str2rgb_lower_case__success(void) { const char *color_str = "f09a1d"; color_rgb_t rgb; color_str2rgb(color_str, &rgb); TEST_ASSERT_EQUAL_INT(0xF0, rgb.r); TEST_ASSERT_EQUAL_INT(0x9A, rgb.g); TEST_ASSERT_EQUAL_INT(0x1D, rgb.b); }
static int handle_post_rgb(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo) { coap_responsecode_t resp = COAP_RSPCODE_CHANGED; const char *str = (const char *) inpkt->payload.p; if (str[0] == '#') { color_str2rgb(&str[1], &rgb); rgbled_set(&led, &rgb); } return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->token, resp, COAP_CONTENTTYPE_TEXT_PLAIN, false); }