Solution (source code)

= Solution

The zero <Fourier coefficient> is $u_0=0$. For a nonzero integer $r$, integrate the two constant halves:
$$
\begin{aligned}
u_r&=\frac{1\,\mathrm V}{4\,\mathrm s}\left[\int_0^{2\,\mathrm s}e^{-ir\omega t}\,dt-\int_{2\,\mathrm s}^{4\,\mathrm s}e^{-ir\omega t}\,dt\right]\\
&=\frac{1-(-1)^r}{i\pi r}\,\mathrm V.
\end{aligned}
$$
Consequently
$$
\boxed{u_0=0,\qquad
u_r=\begin{cases}-2i/(\pi r)\,\mathrm V,&r\text{ odd},\\0,&r\ne0\text{ even}.\end{cases}}
$$
The <complex Fourier series> is $g(t)\sim\sum_{r\in\mathbb Z}u_re^{ir\pi t/(2\,\mathrm s)}$. The negative-index coefficients are the <complex conjugates> of the positive-index ones, as required for a real signal. Combining each pair gives the equivalent real expansion
$$
g(t)\sim\frac{4\,\mathrm V}{\pi}\sum_{j=0}^{\infty}\frac{\sin[(2j+1)\pi t/(2\,\mathrm s)]}{2j+1}.
$$
At a jump, <pointwise convergence of a piecewise smooth Fourier series> gives zero, the average of the two one-sided limits. The value assigned to $g$ at isolated jumps does not affect its <Fourier coefficients> or <mean-square signal power>.