Skip to content

Login Query


The login or identification query informs the server of the type of node initiating the connection, whether it's a client or an mcu.

This query poses an exception from the 4-byte code structure, though it still follows the overall query structure. Instead of using said code, it relies on two constant sequences Client_here and NodeMCU_here, which represent the client node and mcu nodes respectively.

This query has a different behaviour depending on whether it was successful or not. When it succeeds, the server will send no reponse and, on failure, the server will reply with a control query containing an error code identifying the error. The possible error codes that may be returned by the server are:

  • _NACK_InvalidQuery (uint8_t c=255) → If the query format is invalid: contains null-bytes, invalid header or tail sequences, or the query does not follow the structure for the client or mcu login queries.

Client Login Query

The client login query is very straightfoward: The client sends the login query and, assuming there's no unexpected/unknown errors on server-side, the client will be logged to the server successfully. Otherwise, a negative control query will be returned, and the connection will be closed.

The login query is a constant sequence of characters with the form: !s-Client_here-e!.

Client login comm schema Client login comm schema
Diagram for a successful and failed client login query

MCU Login Query

On the other hand, the mcu login query is a little bit more complex. The query will follow a structure similar to the client one, using the constant sequence !s-NodeMCU_here-[info]-e! but with an additional information field, [info], added to the message. This additional field will contain information about the mcu, such as the unique id or name, used to identify the mcu; the number of servos, which indicates how many servos the mcu has; and either a fixed byte value (uint8_t c=187), if the mcu is of the type DumbMCU; or the current position of each of the mcu servos, if the mcu is of the type SmartMCU.

!s-NodeMCU_here-[MCU_UNIQUE_NAME]-[SERVO_COUNT]-[SERVOPOS(0)]-<...>-[SERVOPOS(SERVO_COUNT-1)]-e!
  • [MCU_UNIQUE_NAME] → The unique id used to identify the mcu (char[]).
  • [SERVO_COUNT] → A single uint8_t indicating how many servos the mcu has. Since this number cannot be zero, it does not need any offset applied.
  • [SERVOPOS(i)] → The position of each mcu servo (as a uint8_t), with a dash - between each of them, and ordered by ascending servo ID. Since this value can be zero (0-179 range), by protocol it needs to be offset by +1.
!s-NodeMCU_here-[MCU_UNIQUE_NAME]-[SERVO_COUNT]-[187]-e!
  • [MCU_UNIQUE_NAME] → The unique id used to identify the mcu (char[]).
  • [SERVO_COUNT] → A single uint8_t indicating how many servos the mcu has. Since this number cannot be zero, it does not need any offset applied.
  • [187] → The byte uint8_t b=187. Indicates the server that the mcu is of the type DumbMCU.
Client login comm schema Client login comm schema
Diagram for a successful and failed mcu login query