Let $r_2(n)$ denote the number of ways in which a positive integer $n$ can be expressed as the sum of squares of two integers. Here the sign as well as order of summands matters. Also by convention we set $r_2(0)=1$.
G. H. Hardy mentions the following formula in his book Ramanujan : Twelve Lectures on Subjects Suggested by His Life and Work (see page $82$) $$\sum_{0\leq n<x} \frac{r_2(n)}{\sqrt{x-n}}=2\pi\sqrt {x} +\sum_{n=1}^{\infty} \frac{r_2(n)}{\sqrt{n}}\sin 2\pi\sqrt{nx} \tag{1}$$ This is preceded by mention of another formula of Ramanujan $$\sum_{n = 0}^{\infty}\frac{r_{2}(n)}{\sqrt{n + a}}e^{-2\pi\sqrt{(n + a)b}} = \sum_{n = 0}^{\infty}\frac{r_{2}(n)}{\sqrt{n + b}}e^{-2\pi\sqrt{(n + b)a}}\tag{2}$$ which is proved here. Next Hardy says that the above formula of Ramanujan is valid when $\sqrt{a}, \sqrt{b} $ have positive real parts. Putting $a=xe^{it} $ for $x>0, x\notin\mathbb{Z} ,0<t<\pi$ in $(2)$ and letting $t\to\pi$ followed by equating imaginary parts and setting $b=0$ the relation $(1)$ is obtained.
And then comes the remark "this deduction, of course, is not a proof of $(1)$ and I do not know that there is any proof standing in the literature".
Has a proof of $(1)$ been found since? If so a reference would be greatly appreciated. Can the deduction mentioned above be fixed by making some modification? Any other approaches to prove $(1)$ are also welcome.