Skip to content

@mega-yfue/eufy-sdk / RawDpWriter

Class: RawDpWriter ​

Builds one protobuf message body, field by field.

A field's number and shape are given at the call site, which is the same contract the reader offers in reverse. Nothing here validates that a field number suits the message being built — this layer does not know what message that is, and the capability that does states it in its own field-number table.

Zero-valued fields are the caller's decision, not this writer's. proto3 omits them by default and a device reads an absent field as its zero, so emitting 0 explicitly and omitting it usually mean the same thing — but not always, and only the capability knows which. int therefore writes exactly what it is given, and omitting the call is what leaves the field absent.

Constructors ​

Constructor ​

ts
new RawDpWriter(): RawDpWriter;

Returns ​

RawDpWriter

Methods ​

bool() ​

ts
bool(field, value): this;

A boolean field, on protobuf's own terms: 1 or 0 in a varint.

Parameters ​

field ​

number

value ​

boolean

Returns ​

this


bytes() ​

ts
bytes(field, value): this;

A length-delimited field carrying raw bytes — a string, a blob, or a message built elsewhere.

Parameters ​

field ​

number

value ​

Uint8Array<ArrayBufferLike> | readonly number[]

Returns ​

this


finish() ​

ts
finish(): string;

The finished DP value: varint(bodyLength) ++ body, base64-encoded.

This is the envelope RawDpCodec.decode unwraps, so a value produced here and read back through the codec is a genuine round-trip rather than two implementations of the same guess.

Returns ​

string


int() ​

ts
int(field, value): this;

A varint-valued field (int32, uint32, bool, an enum member).

Parameters ​

field ​

number

value ​

number

Returns ​

this


sint() ​

ts
sint(field, value): this;

A signed varint field (sint32, sint64), ZigZag-encoded — see zigzag.

Parameters ​

field ​

number

value ​

number

Returns ​

this


sub() ​

ts
sub(field, build): this;

A nested sub-message, built by build into a writer of its own.

The sub-message is emitted even when build writes nothing into it. That is not an oversight: an EMPTY sub-message is how these protocols say "this subsystem exists and is in its zero state", as opposed to saying nothing about it, and the readers on the other side of this file depend on the distinction. Omitting the call is what says nothing about it.

Parameters ​

field ​

number

build ​

(w) => void

Returns ​

this


toBytes() ​

ts
toBytes(): readonly number[];

The message body on its own, unframed — for nesting into another writer.

Returns ​

readonly number[]

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.