📜 ⬆️ ⬇️

We program the GSM module M680 OpenCPU



It is probably not a secret for anybody that some GSM modules support downloading applications and can work without an external controlling controller. I want to talk about small experiments with one such module - Neoway M680 OpenCPU .

The ability to download applications directly to the module is good in that it reduces the size and cost of the device. This is not always the best solution, but in some cases it can be really useful. By the way, the size of the M680 OpenCPU is 1.5 by 1.8 cm, so the device can turn out really small.
Available interfaces: UART - 2 pcs., SPI or I2C, ADC - 3 pcs., GPIO - 15 pcs., USB 1.0, PCM, analog microphone inputs - 2 pcs., Analog audio outputs - 3 pcs.

In general, I decided to try connecting a button directly to the GSM module and, when pressed, perform a simple action — call or send an SMS somewhere. The button was soldered to a small debug board of the module, which already has a SIM card holder, power connectors and antennas, to save time. Food - from the battery cell phone.
')
The result is this layout:



The module and OpenCPU documentation can be found here: Neoway M680 OpenCPU

You can get examples of working with the module from the EFO, which are great help at the start.
Control of the AT command module from the application is performed via a virtual UART. To call the phone number, you need to send only one command to the virtual UART: ATD + 7xxxxxxxxxx ;, where + 7xxxxxxxxxx is the desired number. Therefore, making a call for any event is probably one of the simplest applications.

A simple program that calls the specified number when you press a button looks like this:

/***************************************************************************** * Interrupt pin 40 - make a call to phone number +7xxxxxxxxxx *****************************************************************************/ #ifdef __EXAMPLE_HELLOWORLD__ #include "neoway_openplatform.h" U8 AT_MAKE_CALL[] = "ATD+7xxxxxxxxxx;\r"; // AT-     +7xxxxxxxxxx void Neoway_UserInit(void) { Neoway_StopWatchdog(); // watchdog Neoway_InterruptInit(44,NEOWAY_INT_10); // GPIO 44 (pin 40)   10 Neoway_InterruptSetDebounceTime(NEOWAY_INT_10,40); //    (40 ) Neoway_InterruptSetPolarity(NEOWAY_INT_10,NEOWAY_TRUE); //   –      Neoway_InterruptSetTriggerMode(NEOWAY_INT_10,NEOWAY_FALSE); //    } void Neoway_UserTask1(NeowayMsgTypeStruct msg_type,NeowayModuleTypeEnum mod_type) { switch(msg_type.msg_id) { case NEOWAY_MSG_ID_INT_NOTIFY10: Neoway_VirtualUartSend(NEOWAY_MOD_USER1, AT_MAKE_CALL, strlen(AT_MAKE_CALL)); //     break; default : break; } } void Neoway_IntResponse(NeowayIntNumEnum int_no,NeowayModuleTypeEnum mod_id) { if(int_no==NEOWAY_INT_10) { Neoway_SendMsgTask(mod_id,NEOWAY_MOD_USER1,NEOWAY_MSG_ID_INT_NOTIFY10,NULL,0); //         NEOWAY_MSG_ID_INT_NOTIFY10  task1 } } void Neoway_RegisterCallbackFunction(void) { Neoway_RegisterCallBack(NEOWAY_KB_ID_USER_TASK_1,(U32)Neoway_UserTask1); //  Neoway_UserTask1 Neoway_RegisterCallBack(NEOWAY_KB_ID_INT_RESPONSE,(U32)Neoway_IntResponse); //  Neoway_IntResponse } #endif 

GPIO 44, pin 40 is used as the interrupt input. The interrupt input through the button is connected to the VDD_EXT pin, pin 36. When the button is closed, the Neoway_IntResponse function is called, which sends a message to Neoway_UserTask1, and that in turn initiates a call to a predetermined number.
Of course, in this simple program there are no checks, etc., but, nevertheless, it works fine.

If you replace:

 U8 AT_MAKE_CALL[] = "ATD+7xxxxxxxxxx;\r"; 

on
 U8 AT_SMS_TEXT_MODE[] = "AT+CMGF=1\r"; U8 AT_SEND_SMS[] = "AT+CMGS=\"+7xxxxxxxxxx\"\r"; U8 AT_MESSAGE[] = "Hello_HABR!\x1A"; 

and
 Neoway_VirtualUartSend(NEOWAY_MOD_USER1, AT_MAKE_CALL, strlen(AT_MAKE_CALL)); 

on
 Neoway_VirtualUartSend(NEOWAY_MOD_USER1, AT_SMS_TEXT_MODE, strlen(AT_SMS_TEXT_MODE)); Neoway_VirtualUartSend(NEOWAY_MOD_USER1, AT_SEND_SMS, strlen(AT_SEND_SMS)); Neoway_VirtualUartSend(NEOWAY_MOD_USER1, AT_MESSAGE, strlen(AT_MESSAGE)); 

then when pressing the button, the module will send SMS “Hello_HABR!” to the number + 7xxxxxxxxxx.

As a compiler, I used RVDS, taken on one of the torrents.
To compile, run the file cmd.bat from the folder with the example, when successfully completed, among other things, the inscription appears:

************************************************** *****
Done
The target image is the build directory.
************************************************** *****
firmware files appear in the build folder.

If something went wrong, build.log from the same folder helps.

To download the application to the module via UART, the FlashTool program is used:

Flashtool

The download order is as follows:

1. Start FlashTool, set the COM port, speed.
2. Click the Download Agent button and select the MTK_AllInOne_DA.bin file from the program folder.
3. Click the Scatter / Config File button and select the NEOWAY60S_MOD_11B_BB.cfg file from the build folder.
4. We remove the PRIMARY_MAUI daw, leaving only the ROM1 daw.
5. Click the Download button and then turn on the power of the module.
6. Upon successful loading, the “OK” window appears with a green circle - after that you can reload the module and test the result.

I hope someone will come in handy, thank you for your attention!

Source: https://habr.com/ru/post/367745/


All Articles