使用帶有LoRa無線電的Adafruit Feather M0板卡,我想將GPS位置發送到接收器。當試圖創建一個ISO 8601時間戳和我使用下面的代碼來創建一個char
數組,然後經/緯GPS值的數據包發送:類型爲'const char *'和'const char [2]'的無效操作數爲二元運算符+'
char radiopacket[40] = {GPS.year + "-" + GPS.month + "-" + GPS.day + "T" + GPS.hour + ":" + GPS.minute + ":" + GPS.seconds + "Z" + "," + GPS.latitude + "," + GPS.longitude};
rf95.send((uint8_t *)radiopacket, 40);
我不斷收到錯誤:
invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
我哪裏錯了?
'sprintf'是不安全的,請使用'snprintf'代替,見[這裏](https://stackoverflow.com/a/3662918/2666212) – Mike
謝謝!這一直奏效 –