本文整理汇总了C++中put_le16函数的典型用法代码示例。如果您正苦于以下问题:C++ put_le16函数的具体用法?C++ put_le16怎么用?C++ put_le16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put_le16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gxf_write_umf_user_data
static int gxf_write_umf_user_data(ByteIOContext *pb, GXFContext *ctx)
{
offset_t pos = url_ftell(pb);
ctx->umf_user_data_offset = pos - ctx->umf_start_offset;
put_le32(pb, 20);
put_le32(pb, 0);
put_le16(pb, 0);
put_le16(pb, 0);
put_le32(pb, 0);
put_byte(pb, 0);
put_byte(pb, 0);
put_byte(pb, 0);
put_byte(pb, 0);
return 20;
}
示例2: enc_signed_write_cmd
uint16_t enc_signed_write_cmd(uint16_t handle, const uint8_t *value,
size_t vlen, struct bt_crypto *crypto,
const uint8_t csrk[16],
uint32_t sign_cnt,
uint8_t *pdu, size_t len)
{
const uint16_t hdr_len = sizeof(pdu[0]) + sizeof(handle);
const uint16_t min_len = hdr_len + ATT_SIGNATURE_LEN;
if (pdu == NULL)
return 0;
if (vlen > len - min_len)
vlen = len - min_len;
pdu[0] = ATT_OP_SIGNED_WRITE_CMD;
put_le16(handle, &pdu[1]);
if (vlen > 0)
memcpy(&pdu[hdr_len], value, vlen);
if (!bt_crypto_sign_att(crypto, csrk, pdu, hdr_len + vlen, sign_cnt,
&pdu[hdr_len + vlen]))
return 0;
return min_len + vlen;
}
示例3: enable_report_notifications
static void enable_report_notifications(struct report *report,
bool enable_on_device)
{
struct hog_device *hogdev = report->hogdev;
uint8_t value[2];
if (!hogdev->uhid_created)
return;
if (!report->ccc_handle)
return;
/* Register callback for HoG report notifications */
report->notifyid = g_attrib_register(hogdev->attrib,
ATT_OP_HANDLE_NOTIFY,
report->decl->value_handle,
report_value_cb, report, NULL);
if (!enable_on_device)
return;
/* Enable HoG report notifications on the HoG device */
put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
gatt_write_char(hogdev->attrib, report->ccc_handle, value,
sizeof(value), report_ccc_written_cb, report);
}
示例4: gif_write_video
static int gif_write_video(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
ByteIOContext *pb = s->pb;
GIFContext *gif = s->priv_data;
int jiffies;
int64_t delay;
/* graphic control extension block */
put_byte(pb, 0x21);
put_byte(pb, 0xf9);
put_byte(pb, 0x04); /* block size */
put_byte(pb, 0x04); /* flags */
/* 1 jiffy is 1/70 s */
/* the delay_time field indicates the number of jiffies - 1 */
delay = gif->file_time - gif->time;
/* XXX: should use delay, in order to be more accurate */
/* instead of using the same rounded value each time */
/* XXX: don't even remember if I really use it for now */
jiffies = (70*enc->time_base.num/enc->time_base.den) - 1;
put_le16(pb, jiffies);
put_byte(pb, 0x1f); /* transparent color index */
put_byte(pb, 0x00);
gif_image_write_image(pb, 0, 0, enc->width, enc->height,
buf, enc->width * 3, PIX_FMT_RGB24);
put_flush_packet(s->pb);
return 0;
}
示例5: bletest_hci_le_rd_chanmap
int
bletest_hci_le_rd_chanmap(uint16_t handle)
{
int rc;
uint8_t *dst;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_RD_CHANMAP_LEN];
uint8_t rspbuf[BLE_HCI_RD_CHANMAP_RSP_LEN];
uint8_t rsplen;
dst = buf;
ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_CHAN_MAP,
BLE_HCI_RD_CHANMAP_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
put_le16(dst, handle);
rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_CHANMAP_RSP_LEN, &rsplen);
if (rc != 0) {
return rc;
}
if (rsplen != BLE_HCI_RD_CHANMAP_RSP_LEN) {
return BLE_HS_ECONTROLLER;
}
return rc;
}
示例6: exchange_mtu_cb
static void exchange_mtu_cb(uint8_t opcode, const void *pdu,
uint16_t length, void *user_data)
{
struct bt_gatt_server *server = user_data;
uint16_t client_rx_mtu;
uint16_t final_mtu;
uint8_t rsp_pdu[2];
if (length != 2) {
bt_att_send_error_rsp(server->att, opcode, 0,
BT_ATT_ERROR_INVALID_PDU);
return;
}
client_rx_mtu = get_le16(pdu);
final_mtu = MAX(MIN(client_rx_mtu, server->mtu), BT_ATT_DEFAULT_LE_MTU);
/* Respond with the server MTU */
put_le16(server->mtu, rsp_pdu);
bt_att_send(server->att, BT_ATT_OP_MTU_RSP, rsp_pdu, 2, NULL, NULL,
NULL);
/* Set MTU to be the minimum */
server->mtu = final_mtu;
bt_att_set_mtu(server->att, final_mtu);
util_debug(server->debug_callback, server->debug_data,
"MTU exchange complete, with MTU: %u", final_mtu);
}
示例7: discover_descriptor_cb
static void discover_descriptor_cb(guint8 status, const guint8 *pdu,
guint16 len, gpointer user_data)
{
struct scan *scan = user_data;
struct att_data_list *list;
uint8_t *ptr;
uint16_t uuid16, handle;
uint8_t value[2];
uint8_t format;
list = dec_find_info_resp(pdu, len, &format);
if (list == NULL)
return;
if (format != ATT_FIND_INFO_RESP_FMT_16BIT)
goto done;
ptr = list->data[0];
handle = get_le16(ptr);
uuid16 = get_le16(&ptr[2]);
if (uuid16 != GATT_CLIENT_CHARAC_CFG_UUID)
goto done;
put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
gatt_write_char(scan->attrib, handle, value, sizeof(value),
ccc_written_cb, user_data);
done:
att_data_list_free(list);
}
示例8: bt_gatt_server_send_notification
bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
uint16_t handle, const uint8_t *value,
uint16_t length)
{
uint16_t pdu_len;
uint8_t *pdu;
bool result;
if (!server || (length && !value))
return false;
pdu_len = MIN(bt_att_get_mtu(server->att) - 1, length + 2);
pdu = malloc(pdu_len);
if (!pdu)
return false;
put_le16(handle, pdu);
memcpy(pdu + 2, value, pdu_len - 2);
result = !!bt_att_send(server->att, BT_ATT_OP_HANDLE_VAL_NOT, pdu,
pdu_len, NULL, NULL, NULL);
free(pdu);
return result;
}
示例9: hr_msrmt_cb
static bool hr_msrmt_cb(void *user_data)
{
struct server *server = user_data;
bool expended_present = !(server->hr_ee_count % 10);
uint16_t len = 2;
uint8_t pdu[4];
uint32_t cur_ee;
pdu[0] = 0x06;
pdu[1] = 90 + (rand() % 40);
if (expended_present) {
pdu[0] |= 0x08;
put_le16(server->hr_energy_expended, pdu + 2);
len += 2;
}
bt_gatt_server_send_notification(server->gatt,
server->hr_msrmt_handle,
pdu, len);
cur_ee = server->hr_energy_expended;
server->hr_energy_expended = MIN(UINT16_MAX, cur_ee + 10);
server->hr_ee_count++;
return true;
}
示例10: put_payload_parsing_info
static int put_payload_parsing_info(
AVFormatContext *s,
unsigned int sendtime,
unsigned int duration,
int nb_payloads,
int padsize
)
{
ASFContext *asf = s->priv_data;
ByteIOContext *pb = &s->pb;
int ppi_size, i;
unsigned char *start_ppi_ptr = pb->buf_ptr;
int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
put_byte(pb, 0x0);
}
if (asf->multi_payloads_present)
iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT;
if (padsize > 0) {
if (padsize < 256)
iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE;
else
iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD;
}
put_byte(pb, iLengthTypeFlags);
put_byte(pb, ASF_PPI_PROPERTY_FLAGS);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD)
put_le16(pb, padsize - 2);
if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE)
put_byte(pb, padsize - 1);
put_le32(pb, sendtime);
put_le16(pb, duration);
if (asf->multi_payloads_present)
put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
ppi_size = pb->buf_ptr - start_ppi_ptr;
return ppi_size;
}
示例11: voc_write_header
static int voc_write_header(AVFormatContext *s)
{
ByteIOContext *pb = s->pb;
const int header_size = 26;
const int version = 0x0114;
if (s->nb_streams != 1
|| s->streams[0]->codec->codec_type != CODEC_TYPE_AUDIO)
return AVERROR_PATCHWELCOME;
put_buffer(pb, ff_voc_magic, sizeof(ff_voc_magic) - 1);
put_le16(pb, header_size);
put_le16(pb, version);
put_le16(pb, ~version + 0x1234);
return 0;
}
示例12: put_uuid_le
static void put_uuid_le(const bt_uuid_t *uuid, void *dst)
{
if (uuid->type == BT_UUID16)
put_le16(uuid->value.u16, dst);
else
/* Convert from 128-bit BE to LE */
bswap_128(&uuid->value.u128, dst);
}
示例13: put_uuid_le
static inline void put_uuid_le(const bt_uuid_t *src, void *dst)
{
if (src->type == BT_UUID16)
put_le16(src->value.u16, dst);
else
/* Convert from 128-bit BE to LE */
bswap_128(&src->value.u128, dst);
}
示例14: put_str16_nolen
static void put_str16_nolen(ByteIOContext *s, const char *tag)
{
int c;
do{
c = (uint8_t)*tag++;
put_le16(s, c);
}while(c);
}
示例15: avi_write_ix
static int avi_write_ix(AVFormatContext *s)
{
ByteIOContext *pb = s->pb;
AVIContext *avi = s->priv_data;
char tag[5];
char ix_tag[] = "ix00";
int i, j;
assert(!url_is_streamed(pb));
if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
return -1;
for (i=0;i<s->nb_streams;i++) {
AVIStream *avist= s->streams[i]->priv_data;
int64_t ix, pos;
avi_stream2fourcc(&tag[0], i, s->streams[i]->codec->codec_type);
ix_tag[3] = '0' + i;
/* Writing AVI OpenDML leaf index chunk */
ix = url_ftell(pb);
put_tag(pb, &ix_tag[0]); /* ix?? */
put_le32(pb, avist->indexes.entry * 8 + 24);
/* chunk size */
put_le16(pb, 2); /* wLongsPerEntry */
put_byte(pb, 0); /* bIndexSubType (0 == frame index) */
put_byte(pb, 1); /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
put_le32(pb, avist->indexes.entry);
/* nEntriesInUse */
put_tag(pb, &tag[0]); /* dwChunkId */
put_le64(pb, avi->movi_list);/* qwBaseOffset */
put_le32(pb, 0); /* dwReserved_3 (must be 0) */
for (j=0; j<avist->indexes.entry; j++) {
AVIIentry* ie = avi_get_ientry(&avist->indexes, j);
put_le32(pb, ie->pos + 8);
put_le32(pb, ((uint32_t)ie->len & ~0x80000000) |
(ie->flags & 0x10 ? 0 : 0x80000000));
}
put_flush_packet(pb);
pos = url_ftell(pb);
/* Updating one entry in the AVI OpenDML master index */
url_fseek(pb, avist->indexes.indx_start - 8, SEEK_SET);
put_tag(pb, "indx"); /* enabling this entry */
url_fskip(pb, 8);
put_le32(pb, avi->riff_id); /* nEntriesInUse */
url_fskip(pb, 16*avi->riff_id);
put_le64(pb, ix); /* qwOffset */
put_le32(pb, pos - ix); /* dwSize */
put_le32(pb, avist->indexes.entry); /* dwDuration */
url_fseek(pb, pos, SEEK_SET);
}
return 0;
}