Guest User

Untitled

a guest
May 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <CMMC_NB_IoT.h>
  2. #include <AltSoftSerial.h>
  3.  
  4. AltSoftSerial altSerial;
  5. CMMC_NB_IoT nb(&altSerial);
  6.  
  7. void setup() {
  8. Serial.begin(9600);
  9. altSerial.begin(9600);
  10.  
  11. nb.setDebugStream(&Serial);
  12.  
  13. nb.onDeviceReboot([]() {
  14. Serial.println(F("[user] Device being rebooted."));
  15. });
  16.  
  17. nb.onDeviceReady([](CMMC_NB_IoT::DeviceInfo device) {
  18. Serial.println("[user] Device Ready!");
  19. Serial.print(F("# Module IMEI--> "));
  20. Serial.println(device.imei);
  21. Serial.print(F("# Firmware ver--> "));
  22. Serial.println(device.firmware);
  23. Serial.print(F("# IMSI SIM--> "));
  24. Serial.println(device.imsi);
  25. });
  26.  
  27. nb.onConnecting([]() {
  28. Serial.println("[user] Connecting to NB-IoT Network...");
  29. delay(1000);
  30. });
  31.  
  32. nb.onConnected([]() {
  33. Serial.println("[user] NB-IoT Network connected");
  34. });
  35.  
  36. nb.onResponse([](CMMC_NB_IoT::UDPReceive resp){
  37. Serial.println("socket : ");
  38. Serial.print(resp.socket);
  39. Serial.println("ip_address : ");
  40. Serial.print(resp.ip_address);
  41. Serial.println("port : ");
  42. Serial.print(resp.port);
  43. Serial.println("length : ");
  44. Serial.print(resp.length);
  45. Serial.println("data : ");
  46. Serial.print(resp.data);
  47. Serial.println("remaining_length : ");
  48. Serial.print(resp.remaining_length);
  49. });
  50.  
  51.  
  52. nb.begin();
  53. }
  54.  
  55. void loop() {
  56. nb.loop();
  57. }
Add Comment
Please, Sign In to add comment