(action: string, payload: any)
| 158 | } |
| 159 | |
| 160 | private async call(action: string, payload: any): Promise<any> { |
| 161 | return new Promise((resolve, reject) => { |
| 162 | const messageId = (++this.messageId).toString(); |
| 163 | const message = [2, messageId, action, payload]; |
| 164 | |
| 165 | // Setup callback for response |
| 166 | this.pendingCallbacks.set(messageId, resolve); |
| 167 | |
| 168 | // Send message |
| 169 | this.send(message); |
| 170 | |
| 171 | // Timeout after 10 seconds |
| 172 | setTimeout(() => { |
| 173 | if (this.pendingCallbacks.has(messageId)) { |
| 174 | this.pendingCallbacks.delete(messageId); |
| 175 | reject(new Error(`Timeout waiting for response to ${action}`)); |
| 176 | } |
| 177 | }, 10000); |
| 178 | }); |
| 179 | } |
| 180 | |
| 181 | async bootNotification(model = "Simulator", vendor = "evcc-test"): Promise<any> { |
| 182 | return this.call("BootNotification", { |
no test coverage detected